package com.rs.game.player;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.io.*;
import java.util.Calendar;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.io.BufferedWriter;

import com.rs.Settings;
import com.rs.cores.CoresManager;
//import com.rs.event.Event;
//import com.rs.event.EventContainer;
//import com.rs.event.EventManager;
import com.rs.game.Animation;
import com.rs.game.Entity;
import com.rs.game.ForceTalk;
import com.rs.game.Graphics;
import com.rs.game.Hit;
import com.rs.game.World;
import com.rs.game.WorldObject;
import com.rs.game.WorldTile;
import com.rs.game.Hit.HitLook;
import com.rs.game.item.FloorItem;
import com.rs.game.item.Item;
import com.rs.game.item.ItemsContainer;
import com.rs.game.minigames.clanwars.FfaZone;
import com.rs.game.minigames.clanwars.WarControler;
import com.rs.game.minigames.duel.DuelArena;
import com.rs.game.minigames.duel.DuelRules;
import com.rs.game.minigames.RecipeforDisaster;
import com.rs.game.npc.NPC;
import com.rs.game.npc.familiar.Familiar;
import com.rs.game.npc.godwars.zaros.Nex;
import com.rs.game.npc.pet.Pet;
import com.rs.game.player.SpinsManager;
import com.rs.game.player.QuestManager.Quests;
import com.rs.game.player.actions.PlayerCombat;
import com.rs.game.player.content.*;
import com.rs.game.player.content.GildedAltar.bonestoOffer;
import com.rs.game.player.content.RingOfWealth.rare_drop;
import com.rs.game.player.content.SlayerTask.Master;
import com.rs.game.player.content.construction.House;
import com.rs.game.player.content.construction.Room;
import com.rs.game.player.content.construction.RoomReference;
import com.rs.game.player.content.construction.RoomConstruction;
import com.rs.game.player.content.pet.PetManager;
import com.rs.game.player.controlers.CorpBeastControler;
import com.rs.game.player.controlers.CrucibleControler;
import com.rs.game.player.controlers.DTControler;
import com.rs.game.player.controlers.FightCaves;
import com.rs.game.player.controlers.FightKiln;
import com.rs.game.player.controlers.GodWars;
import com.rs.game.player.controlers.NomadsRequiem;
import com.rs.game.player.controlers.QueenBlackDragonController;
import com.rs.game.player.controlers.Wilderness;
import com.rs.game.player.controlers.ZGDControler;
import com.rs.game.player.controlers.castlewars.CastleWarsPlaying;
import com.rs.game.player.controlers.castlewars.CastleWarsWaiting;
import com.rs.game.player.controlers.fightpits.FightPitsArena;
import com.rs.game.player.controlers.pestcontrol.PestControlGame;
import com.rs.game.player.controlers.pestcontrol.PestControlLobby;
import com.rs.game.player.controlers.HouseControler;
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;
import com.rs.net.Session;
import com.rs.net.decoders.WorldPacketsDecoder;
import com.rs.net.decoders.handlers.ButtonHandler;
import com.rs.net.encoders.WorldPacketsEncoder;
import com.rs.utils.IsaacKeyPair;
import com.rs.utils.Logger;
import com.rs.utils.MachineInformation;
import com.rs.utils.PkRank;
import com.rs.utils.SQL;
import com.rs.utils.SerializableFilesManager;
import com.rs.utils.Text;
import com.rs.utils.Utils;
import com.rs.utils.Utils.EntityDirection;

public class Player extends Entity {
	public static final int TELE_MOVE_TYPE = 127, WALK_MOVE_TYPE = 1,
			RUN_MOVE_TYPE = 2;
	public boolean DoneServerManager;
	private boolean DoneTutorial;
	private static final long serialVersionUID = 2011932556974180375L;
	public boolean ClaimedReward;
	public static int boxWon = -1;
	public int isspining;
	public int Rewards;
	public int spins;
	public boolean trollReward;
	private int trollsToKill;
	private int trollsKilled;
	private transient TimeOnline timeOnline;
	private transient String username;
	private transient Session session;
	private transient boolean clientLoadedMapRegion;
	private transient int displayMode;
	private transient int screenWidth;
	public boolean trustedflower = true;
	private transient int screenHeight;
	private transient InterfaceManager interfaceManager;
	private transient DialogueManager dialogueManager;
	private transient ConstructFurniture con;
	private transient Mission mission;
	private transient SpinsManager spinsManager;
	private transient LoyaltyManager loyaltyManager;
	private transient AFKManager afkManager;
	private transient DwarfCannon dwarfCannon;
	private transient HintIconsManager hintIconsManager;
	private transient ActionManager actionManager;
	private transient CutscenesManager cutscenesManager;
	private transient PriceCheckManager priceCheckManager;
	private transient CoordsEvent coordsEvent;
	private transient FriendChatsManager currentFriendChat;
	private transient Trade trade;
	private transient DuelRules lastDuelRules;
	private transient IsaacKeyPair isaacKeyPair;
	private transient Pet pet;
	private transient ShootingStar ShootingStar;
	private transient House house;
	private transient Room rooms;
	private transient HouseControler HouseControler;
	private transient PinManager pinManager;
	public static ItemsContainer<Item> items = new ItemsContainer<Item>(13, true);
	public int firstColumn = 1, secondColumn = 1, thirdColumn = 1;

	// Squeal
	public void refreshSqueal() {
		getPackets().sendConfigByFile(11026, getSpins() + 1);
	}

	public void setSpins(int spins) {
		this.spins = spins;
	}

	public int getSpins() {
		return spins;
	}

	public Item getBox() {
		Item[] box = items.getItems();
		return box[Rewards];
	}

	// used for packets logic
	private transient ConcurrentLinkedQueue<LogicPacket> logicPackets;

	// used for update
	private transient LocalPlayerUpdate localPlayerUpdate;
	private transient LocalNPCUpdate localNPCUpdate;

	private int temporaryMovementType;
	private boolean updateMovementType;

	// Dragon fire shield (Counts charges)
	public int DFS = 0;

	public void DfsSpec(final int shieldId) {
		if (combatDefinitions.hasDfs()) {

		}

	}
	
    //time online
	public int time = 0;
	
	// Dwarf Cannon Quest
	public boolean railing1;
	public boolean railing2;
	public boolean railing3;
	public boolean railing4;
	public boolean railing5;
	public boolean railing6;
	public boolean allRailing;

	// Lost-City Quest
	public boolean recievedRunes = false;
	public boolean spawnedBossLC = false;

	public void lostCity() {
		if (getQuestManager().getQuestStage(Quests.LOST_CITY) == 4) {
			setQuestPoints(getQuestPoints() + 3);
			getInterfaceManager().sendInterface(277);
			getInventory().addItem(10551, 1);
			getPackets().sendItemOnIComponent(277, 5, 772, 1);
			getPackets().sendIComponentText(277, 4, "You have completed Lost City!");
			getPackets().sendIComponentText(277, 7, "" + getQuestPoints());
			getPackets().sendIComponentText(277, 10, "3 Quest Points");
			getPackets().sendIComponentText(277, 11, "Access to Zanaris");
			getPackets().sendIComponentText(277, 12, "Double spin ticket");
			getPackets().sendIComponentText(277, 13, "Fighter Torso");
			getPackets().sendIComponentText(277, 14, "");
			getPackets().sendIComponentText(277, 15, "");
			getPackets().sendIComponentText(277, 16, "");
			getPackets().sendIComponentText(277, 17, "");
			getInventory().addItem(24155, 1);
			getQuestManager().completeQuest(Quests.LOST_CITY);
		}
	}

	// Boss Kills
	public int bork = 0;
	public int nex = 0;
	public int bandos = 0;
	public int saradomin = 0;
	public int armadyl = 0;
	public int zamorak = 0;
	public int thunder = 0;
	public int corp = 0;
	public int glacors = 0;
	public int skele = 0;

	// farming patch stuff
	private int faladorHerbPatch;
	private int faladorNorthAllotmentPatch;
	private int faladorSouthAllotmentPatch;
	private int faladorFlowerPatch;
	private boolean faladorHerbPatchRaked;
	private boolean faladorNorthAllotmentPatchRaked;
	private boolean faladorSouthAllotmentPatchRaked;
	private boolean faladorFlowerPatchRaked;

	// Lsmessage
	private boolean lootshareEnabled;

	// player stages
	private transient boolean started;
	private transient boolean running;

	// Used For HomeTeleports
	public boolean Ass = false;
	public boolean Gnome = false;
	public boolean Demon = false;
	public boolean Pony = false;
	public boolean SuperJump = true;

	private transient long packetsDecoderPing;
	private transient boolean resting;
	private transient boolean canPvp;
	private transient boolean cantTrade;
	private transient long lockDelay; // used for doors and stuff like that
	private transient long foodDelay;
	private transient long potDelay;
	private transient long boneDelay;
	private transient Runnable closeInterfacesEvent;
	private transient long lastPublicMessage;
	private transient long polDelay;
	private transient List<Integer> switchItemCache;
	private transient boolean disableEquip;
	private transient boolean spawnsMode;
	private transient boolean castedVeng;
	private transient boolean CastedHumidify;
	private transient boolean invulnerable;
	private transient double hpBoostMultiplier;
	private transient boolean largeSceneView;

	// interface

	// saving stuff
	private PlayerData playerData;
	private String password;
	private int rights;
	private String displayName;
	private String lastIP;
	private long creationDate;
	private Appearence appearence;
	private Inventory inventory;
	private Equipment equipment;
	private Skills skills;
	public int coins;
	private CombatDefinitions combatDefinitions;
	private Prayer prayer;
	private Bank bank;
	private ControlerManager controlerManager;
	private MusicsManager musicsManager;
	private EmotesManager emotesManager;
	private FriendsIgnores friendsIgnores;
	private DominionTower dominionTower;
	private Familiar familiar;
	private AuraManager auraManager;
	private QuestManager questManager;
	private PetManager petManager;
	private Master master;
	private byte runEnergy;
	private boolean allowChatEffects;
	private boolean mouseButtons;
	private int privateChatSetup;
	private int friendChatSetup;
	private int skullDelay;
	private int skullId;
	private boolean forceNextMapLoadRefresh;
	private long poisonImmune;
	private long fireImmune;
	private boolean killedQueenBlackDragon;
	private int runeSpanPoints;
	private double blackmarks;
	private int lastEffigy;
	public boolean openedEffigy;
	private boolean acceptAid;
	
	private int lastBonfire;
	private int[] pouches;
	private long displayTime;
	private long muted;
	private long jailed;
	private long banned;
	private boolean permBanned;
	private boolean filterGame;
	private boolean xpLocked;
	private boolean yellOff;
	// game bar status
	private int publicStatus;
	private int clanStatus;
	private int tradeStatus;
	private int assistStatus;
	private boolean inClops;
	private int wGuildTokens;
	public boolean accountPinSet;
	private int accountPin;

	// cannon stuff
	public int cannonType;
	public boolean hasCannon;

	private boolean donator;
	private boolean extremeDonator;

	private boolean staff;

	// Recovery ques. & ans.
	private String recovQuestion;
	private String recovAnswer;

	private String lastMsg;

	// Slayer
	private SlayerTask task;
	public boolean learnBroad;
	public boolean learnRing;
	public boolean learnHelm;

	private int questPoints;

	// honor
	private int killCount, deathCount;
	private ChargesManager charges;
	// barrows
	private boolean[] killedBarrowBrothers;
	private int hiddenBrother;
	private int barrowsKillCount;
	private int pestPoints;

	// Penguins
	public int penguinreward = 0;
	public int penguin1 = 0;
	public int penguin2 = 0;
	public int penguin3 = 0;
	public int penguin4 = 0;
	public int penguin5 = 0;
	public int penguin6 = 0;
	public int penguin7 = 0;
	public int totalpenguins = 0;

	public int totalpenguins2 = 0;

	public int gettotalpeng2() {
		return totalpenguins2;
	}

	public int gettotalpeng() {
		return totalpenguins;
	}

	public int getpenguin1() {
		return penguin1;
	}

	public int getpenguin2() {
		return penguin2;
	}

	public int getpenguin3() {
		return penguin3;
	}

	public int getpenguin4() {
		return penguin4;
	}

	public int getpenguin5() {
		return penguin5;
	}

	public int getpenguin6() {
		return penguin6;
	}

	public int getpenguin7() {
		return penguin7;
	}

	// achievement stuff
	public int barrowsCount;
	public int crystalChests;
	public int shrimp;
	public int lobsters;
	public int swordfish;
	public int normalLogs;
	public int oakLogs;
	public int mapleLogs;
	public int cooked;
	public int logsBurnt;
	public int taskCount;
	public int gnomeCourse;
	public int barbCourse;
	public int advancedGnomeCourse;
	public int advancedBarbCourse;

	// more achievement stuff
	public boolean fishOutfit;
	public boolean cookGaunt;
	public boolean lumberjackOutfit;
	public boolean fireRing;
	public boolean flameGlove;
	public boolean infernoAdze;
	public boolean agileLegs;
	public boolean agileTop;
	public boolean maxedCape;
	public boolean completionistCape;
	public boolean completionistCapeT;

	public boolean zenRest;

	// skill capes customizing
	private int[] maxedCapeCustomized;
	private int[] completionistCapeCustomized;

	// completionistcape reqs
	private boolean completedFightCaves;
	private boolean completedFightKiln;
	private boolean wonFightPits;

	// crucible
	private boolean talkedWithMarv;
	private int crucibleHighScore;

	private double donatedAmount;

	private int overloadDelay;
	private int prayerRenewalDelay;

	private String currentFriendChatOwner;
	private int summoningLeftClickOption;
	private List<String> ownedObjectsManagerKeys;

	// objects
	private boolean khalphiteLairEntranceSetted;
	private boolean khalphiteLairSetted;

	// supportteam
	private boolean isSupporter;

	// voting
	private boolean oldItemsLook;

	private String yellColor;

	private boolean isGraphicDesigner;
	private boolean isDeveloper;

	private int slayerPoints;
	private int Loyaltypoints;
	private int VotePoints;
	
	private long afkTime;
	private boolean afk;

	// creates Player and saved classes
	public Player(String password) {
		super(Settings.START_PLAYER_LOCATION);
		setHitpoints(Settings.START_PLAYER_HITPOINTS);
		this.password = password;
		appearence = new Appearence();
		inventory = new Inventory();
		equipment = new Equipment();
		skills = new Skills();
		combatDefinitions = new CombatDefinitions();
		prayer = new Prayer();
		bank = new Bank();
		controlerManager = new ControlerManager();
		musicsManager = new MusicsManager();
		emotesManager = new EmotesManager();
		friendsIgnores = new FriendsIgnores();
		dominionTower = new DominionTower();
		charges = new ChargesManager();
		auraManager = new AuraManager();
		questManager = new QuestManager();
		petManager = new PetManager();
		runEnergy = 100;
		allowChatEffects = true;
		mouseButtons = true;
		acceptAid = false;
		pouches = new int[4];
		resetBarrows();
		SkillCapeCustomizer.resetSkillCapes(this);
		ownedObjectsManagerKeys = new LinkedList<String>();
		setCreationDate(Utils.currentTimeMillis());
	}

	public void init(Session session, String username, int displayMode, int screenWidth, int screenHeight, MachineInformation machineInformation, IsaacKeyPair isaacKeyPair) {
		// temporary deleted after reset all chars
		if (dominionTower == null)
			dominionTower = new DominionTower();
		if (auraManager == null)
			auraManager = new AuraManager();
		if (questManager == null)
			questManager = new QuestManager();
		if (ShootingStar == null)
			ShootingStar = new ShootingStar();
		if (petManager == null)
			petManager = new PetManager();
		if (playerData == null)
			playerData = new PlayerData();
		if (house == null)
			house = new House();
		if (HouseControler == null)
			HouseControler = new HouseControler();
		if (RoomConstruction == null)
			RoomConstruction = new RoomConstruction(this);
		if (pinManager == null)
			pinManager = new PinManager();
		this.session = session;
		this.username = username;
		this.displayMode = displayMode;
		this.screenWidth = screenWidth;
		this.screenHeight = screenHeight;
		this.isaacKeyPair = isaacKeyPair;
		notes = new Notes(this);
		timeOnline = new TimeOnline(this);
		interfaceManager = new InterfaceManager(this);
		dialogueManager = new DialogueManager(this);
		spinsManager = new SpinsManager(this);
		loyaltyManager = new LoyaltyManager(this);
		afkManager = new AFKManager(this);
		hintIconsManager = new HintIconsManager(this);
		priceCheckManager = new PriceCheckManager(this);
		localPlayerUpdate = new LocalPlayerUpdate(this);
		localNPCUpdate = new LocalNPCUpdate(this);
		actionManager = new ActionManager(this);
		cutscenesManager = new CutscenesManager(this);
		trade = new Trade(this);
		dwarfCannon = new DwarfCannon(this);
		// loads player on saved instances
		appearence.setPlayer(this);
		inventory.setPlayer(this);
		equipment.setPlayer(this);
		skills.setPlayer(this);
		combatDefinitions.setPlayer(this);
		prayer.setPlayer(this);
		bank.setPlayer(this);
		controlerManager.setPlayer(this);
		pinManager.setPlayer(this);
		musicsManager.setPlayer(this);
		emotesManager.setPlayer(this);
		friendsIgnores.setPlayer(this);
		dominionTower.setPlayer(this);
		auraManager.setPlayer(this);
		charges.setPlayer(this);
		questManager.setPlayer(this);
		petManager.setPlayer(this);
		setDirection(Utils.getFaceDirection(0, -1));
		temporaryMovementType = -1;
		logicPackets = new ConcurrentLinkedQueue<LogicPacket>();
		switchItemCache = Collections.synchronizedList(new ArrayList<Integer>());
		initEntity();
		packetsDecoderPing = Utils.currentTimeMillis();
		World.addPlayer(this);
		World.updateEntityRegion(this);
	}

	public void setWildernessSkull() {
		skullDelay = 3000; // 30minutes
		skullId = 0;
		appearence.generateAppearenceData();
	}

	public void setFightPitsSkull() {
		skullDelay = Integer.MAX_VALUE; // infinite
		skullId = 1;
		appearence.generateAppearenceData();
	}

	public void setSkullInfiniteDelay(int skullId) {
		skullDelay = Integer.MAX_VALUE; // infinite
		this.skullId = skullId;
		appearence.generateAppearenceData();
	}

	public void removeSkull() {
		skullDelay = -1;
		appearence.generateAppearenceData();
	}

	public boolean lootshareEnabled() {
		return this.lootshareEnabled;
	}

	public void toggleLootShare() {
		this.lootshareEnabled = !this.lootshareEnabled;
		getPackets().sendConfig(1083, this.lootshareEnabled ? 1 : 0);
		sendMessage(String.format("<img=1>LS_Manager: <col=115b0d>Lootshare is now %sactive!</col>", this.lootshareEnabled ? "" : "in"));
	}

	public boolean hasSkull() {
		return skullDelay > 0;
	}

	public int setSkullDelay(int delay) {
		return this.skullDelay = delay;
	}

	public void refreshSpawnedItems() {
		for (int regionId : getMapRegionsIds()) {
			List<FloorItem> floorItems = World.getRegion(regionId).getFloorItems();
			if (floorItems == null)
				continue;
			for (FloorItem item : floorItems) {
				if ((item.isInvisible() || item.isGrave()) && this != item.getOwner() || item.getTile().getPlane() != getPlane())
					continue;
				getPackets().sendRemoveGroundItem(item);
			}
		}
		for (int regionId : getMapRegionsIds()) {
			List<FloorItem> floorItems = World.getRegion(regionId).getFloorItems();
			if (floorItems == null)
				continue;
			for (FloorItem item : floorItems) {
				if ((item.isInvisible() || item.isGrave()) && this != item.getOwner() || item.getTile().getPlane() != getPlane())
					continue;
				getPackets().sendGroundItem(item);
			}
		}
	}

	public void refreshSpawnedObjects() {
		for (int regionId : getMapRegionsIds()) {
			List<WorldObject> spawnedObjects = World.getRegion(regionId).getSpawnedObjects();
			if (spawnedObjects != null) {
				for (WorldObject object : spawnedObjects)
					if (object.getPlane() == getPlane())
						getPackets().sendSpawnedObject(object);
			}
			List<WorldObject> removedObjects = World.getRegion(regionId).getRemovedObjects();
			if (removedObjects != null) {
				for (WorldObject object : removedObjects)
					if (object.getPlane() == getPlane())
						getPackets().sendDestroyObject(object);
			}
		}
	}

	// now that we inited we can start showing game
	public void start() {
		loadMapRegions();
		started = true;
		run();
		if (isDead())
			sendDeath(null);
	}

	public void stopAll() {
		stopAll(true);
	}

	public void stopAll(boolean stopWalk) {
		stopAll(stopWalk, true);
	}

	public void stopAll(boolean stopWalk, boolean stopInterface) {
		stopAll(stopWalk, stopInterface, true);
	}

	// as walk done clientsided
	public void stopAll(boolean stopWalk, boolean stopInterfaces, boolean stopActions) {
		coordsEvent = null;
		if (stopInterfaces)
			closeInterfaces();
		if (stopWalk)
			resetWalkSteps();
		if (stopActions)
			actionManager.forceStop();
		combatDefinitions.resetSpells(false);
		bonestoOffer.stopOfferGod = true;
	}

	@Override
	public void reset(boolean attributes) {
		super.reset(attributes);
		refreshHitPoints();
		hintIconsManager.removeAll();
		skills.restoreSkills();
		combatDefinitions.resetSpecialAttack();
		prayer.reset();
		combatDefinitions.resetSpells(true);
		resting = false;
		bonestoOffer.stopOfferGod = true;
		skullDelay = 0;
		foodDelay = 0;
		potDelay = 0;
		poisonImmune = 0;
		fireImmune = 0;
		castedVeng = false;
		CastedHumidify = false;
		setRunEnergy(100);
		appearence.generateAppearenceData();
	}

	@Override
	public void reset() {
		reset(true);
	}

	public void closeInterfaces() {
		if (interfaceManager.containsScreenInter())
			interfaceManager.closeScreenInterface();
		if (interfaceManager.containsInventoryInter())
			interfaceManager.closeInventoryInterface();
		dialogueManager.finishDialogue();
		if (closeInterfacesEvent != null) {
			closeInterfacesEvent.run();
			closeInterfacesEvent = null;
		}
	}

	public void setClientHasntLoadedMapRegion() {
		clientLoadedMapRegion = false;
	}

	@Override
	public void loadMapRegions() {
		boolean wasAtDynamicRegion = isAtDynamicRegion();
		super.loadMapRegions();
		clientLoadedMapRegion = false;
		if (isAtDynamicRegion()) {
			getPackets().sendDynamicMapRegion(!started);
			if (!wasAtDynamicRegion)
				localNPCUpdate.reset();
		} else {
			getPackets().sendMapRegion(!started);
			if (wasAtDynamicRegion)
				localNPCUpdate.reset();
		}
		forceNextMapLoadRefresh = false;
	}

	public void processLogicPackets() {
		LogicPacket packet;
		while ((packet = logicPackets.poll()) != null)
			WorldPacketsDecoder.decodeLogicPacket(this, packet);
	}

	@Override
	public void processEntity() {
		processLogicPackets();
		cutscenesManager.process();
		if (coordsEvent != null && coordsEvent.processEvent(this))
			coordsEvent = null;
		super.processEntity();
		if (musicsManager.musicEnded())
			musicsManager.replayMusic();
		if (hasSkull()) {
			skullDelay--;
			if (!hasSkull())
				appearence.generateAppearenceData();
		}
		if (polDelay != 0 && polDelay <= Utils.currentTimeMillis()) {
			getPackets().sendGameMessage("The power of the light fades. Your resistance to melee attacks return to normal.");
			polDelay = 0;
		}
		if (overloadDelay > 0) {
			if (overloadDelay == 1 || isDead()) {
				Pots.resetOverLoadEffect(this);
				return;
			} else if ((overloadDelay - 1) % 25 == 0)
				Pots.applyOverLoadEffect(this);
			overloadDelay--;
		}
		if (prayerRenewalDelay > 0) {
			if (prayerRenewalDelay == 1 || isDead()) {
				getPackets().sendGameMessage("<col=0000FF>Your prayer renewal has ended.");
				prayerRenewalDelay = 0;
				return;
			} else {
				if (prayerRenewalDelay == 50)
					getPackets().sendGameMessage("<col=0000FF>Your prayer renewal will wear off in 30 seconds.");
				if (!prayer.hasFullPrayerpoints()) {
					getPrayer().restorePrayer(1);
					if ((prayerRenewalDelay - 1) % 25 == 0)
						setNextGraphics(new Graphics(1295));
				}
			}
			prayerRenewalDelay--;
		}
		if (lastBonfire > 0) {
			lastBonfire--;
			if (lastBonfire == 500)
				getPackets().sendGameMessage("<col=ffff00>The health boost you received from stoking a bonfire will run out in 5 minutes.");
			else if (lastBonfire == 0) {
				getPackets().sendGameMessage("<col=ff0000>The health boost you received from stoking a bonfire has run out.");
				equipment.refreshConfigs(false);
			}
		}
		charges.process();
		auraManager.process();
		actionManager.process();
		prayer.processPrayer();
		controlerManager.process();

	}

	@Override
	public void processReceivedHits() {
		if (lockDelay > Utils.currentTimeMillis())
			return;
		super.processReceivedHits();
	}

	@Override
	public boolean needMasksUpdate() {
		return super.needMasksUpdate() || temporaryMovementType != -1 || updateMovementType;
	}


	@Override
	public void resetMasks() {
		super.resetMasks();
		temporaryMovementType = -1;
		updateMovementType = false;
		if (!clientHasLoadedMapRegion()) {
			// load objects and items here
			setClientHasLoadedMapRegion();
			refreshSpawnedObjects();
			refreshSpawnedItems();
		}
	}

	public void toogleRun(boolean update) {
		super.setRun(!getRun());
		updateMovementType = true;
		if (update)
			sendRunButtonConfig();
	}

	public void setRunHidden(boolean run) {
		super.setRun(run);
		updateMovementType = true;
	}

	@Override
	public void setRun(boolean run) {
		if (run != getRun()) {
			super.setRun(run);
			updateMovementType = true;
			sendRunButtonConfig();
		}
	}

	public void sendRunButtonConfig() {
		getPackets().sendConfig(173, resting ? 3 : getRun() ? 1 : 0);
	}

	public void restoreRunEnergy() {
		if (getNextRunDirection() == -1 && runEnergy < 100) {
			runEnergy++;
			if (resting && runEnergy < 100)
				runEnergy++;
			getPackets().sendRunEnergy();
		}
	}

	public int conRoom = 0;

	public void buildRoomSouth() {// Doesnt work
		switch (conRoom) {
		case 1:
			rooms.add(new RoomReference(Room.PARLOUR, 4, 3, 0, 0));
			break;
		case 2:
			rooms.add(new RoomReference(Room.KITCHEN, getChunkX(), getChunkY() - 1, 0, 0));
			break;
		case 3:
			rooms.add(new RoomReference(Room.DININGROOM, getChunkX(), getChunkY() - 1, 0, 0));
			break;
		}
	}

	/**
	 * Construction
	 */
	public boolean portal1 = false;
	public boolean portal2 = false;
	public boolean portal3 = false;

	public boolean inBuildMode = false;
	public boolean canEnter = false;
	public boolean isOwner = false;
	public boolean hasLocked = false;
	public boolean hasRemovedObjects = false;

	public boolean hasHouse = false;

	/**
	 * Butlers
	 */
	public boolean hasBoughtDemon = false;
	public boolean spokeToDemon = false;
	public boolean spokeToAgent = false;

	/**
	 * 1 = Teak Frame 2 = Mahogany Frame
	 */
	public int portalTele1 = 0;
	public int portalTele2 = 0;
	public int portalTele3 = 0;
	public int portalFrame = 0;

	/**
	 * 1 = Crude chair 2 = Rocking chair 3 = Oak armchair 4 = Teak armchair
	 */

	public int chair = 0;
	public int throne = 0;
	public int tree = 0;
	public int bookcase = 0;
	public int firePlace = 0;
	public int altar = 0;

	public void refreshObjects(final int[] boundChuncks) {
		WorldTasksManager.schedule(new WorldTask() {
			int loop;

			@Override
			public void run() {
				if (loop == 50) {
					checkObjects(boundChuncks);
				} else if (loop == 100) {
					checkObjects(boundChuncks);
				} else if (loop == 150) {
					checkObjects(boundChuncks);
				} else if (loop == 200) {
					checkObjects(boundChuncks);
				} else if (loop == 500) {
					checkObjects(boundChuncks);
				}
				loop++;
			}
		}, 0, 1);
	}

	public void checkObjects(final int[] boundChuncks) {
		WorldTasksManager.schedule(new WorldTask() {
			int loop;

			@Override
			public void run() {
				if (loop == 1) {
					closeInterfaces();
					World.spawnObject(new WorldObject(13405, 10, 0, boundChuncks[0] * 8 + 35, boundChuncks[1] * 8 + 35, 0), true);
					if (chair == 1) {
						World.spawnObject(new WorldObject(13581, 10, 0, boundChuncks[0] * 8 + 42, boundChuncks[1] * 8 + 36, 0), true);
						World.spawnObject(new WorldObject(13581, 10, 0, boundChuncks[0] * 8 + 44, boundChuncks[1] * 8 + 35, 0), true);
						World.spawnObject(new WorldObject(13581, 10, 0, boundChuncks[0] * 8 + 45, boundChuncks[1] * 8 + 36, 0), true);
					} else if (chair == 2) {
						World.spawnObject(new WorldObject(13583, 10, 0, boundChuncks[0] * 8 + 42, boundChuncks[1] * 8 + 36, 0), true);
						World.spawnObject(new WorldObject(13583, 10, 0, boundChuncks[0] * 8 + 44, boundChuncks[1] * 8 + 35, 0), true);
						World.spawnObject(new WorldObject(13583, 10, 0, boundChuncks[0] * 8 + 45, boundChuncks[1] * 8 + 36, 0), true);
					} else if (chair == 3) {
						World.spawnObject(new WorldObject(13584, 10, 0, boundChuncks[0] * 8 + 42, boundChuncks[1] * 8 + 36, 0), true);
						World.spawnObject(new WorldObject(13584, 10, 0, boundChuncks[0] * 8 + 44, boundChuncks[1] * 8 + 35, 0), true);
						World.spawnObject(new WorldObject(13584, 10, 0, boundChuncks[0] * 8 + 45, boundChuncks[1] * 8 + 36, 0), true);
					} else if (chair == 4) {
						World.spawnObject(new WorldObject(13587, 10, 0, boundChuncks[0] * 8 + 42, boundChuncks[1] * 8 + 36, 0), true);
						World.spawnObject(new WorldObject(13587, 10, 0, boundChuncks[0] * 8 + 44, boundChuncks[1] * 8 + 35, 0), true);
						World.spawnObject(new WorldObject(13587, 10, 0, boundChuncks[0] * 8 + 45, boundChuncks[1] * 8 + 36, 0), true);
					}
					if (throne == 1) {
						World.spawnObject(new WorldObject(13665, 10, 3, boundChuncks[0] * 8 + 25, boundChuncks[1] * 8 + 36, 0), true);
						World.spawnObject(new WorldObject(13665, 10, 3, boundChuncks[0] * 8 + 25, boundChuncks[1] * 8 + 35, 0), true);
					} else if (throne == 2) {
						World.spawnObject(new WorldObject(13670, 10, 3, boundChuncks[0] * 8 + 25, boundChuncks[1] * 8 + 36, 0), true);
						World.spawnObject(new WorldObject(13670, 10, 3, boundChuncks[0] * 8 + 25, boundChuncks[1] * 8 + 35, 0), true);
					} else if (throne == 3) {
						World.spawnObject(new WorldObject(13671, 10, 3, boundChuncks[0] * 8 + 25, boundChuncks[1] * 8 + 36, 0), true);
						World.spawnObject(new WorldObject(13671, 10, 3, boundChuncks[0] * 8 + 25, boundChuncks[1] * 8 + 35, 0), true);
					}
					if (tree == 1) {
						World.spawnObject(new WorldObject(13413, 10, 0, boundChuncks[0] * 8 + 33, boundChuncks[1] * 8 + 37, 0), true);
						World.spawnObject(new WorldObject(13413, 10, 0, boundChuncks[0] * 8 + 38, boundChuncks[1] * 8 + 38, 0), true);
					} else if (tree == 2) {
						World.spawnObject(new WorldObject(13414, 10, 0, boundChuncks[0] * 8 + 33, boundChuncks[1] * 8 + 37, 0), true);
						World.spawnObject(new WorldObject(13414, 10, 0, boundChuncks[0] * 8 + 38, boundChuncks[1] * 8 + 38, 0), true);
					} else if (tree == 3) {
						World.spawnObject(new WorldObject(13416, 10, 0, boundChuncks[0] * 8 + 33, boundChuncks[1] * 8 + 37, 0), true);
						World.spawnObject(new WorldObject(13416, 10, 0, boundChuncks[0] * 8 + 38, boundChuncks[1] * 8 + 38, 0), true);
					} else if (tree == 4) {
						World.spawnObject(new WorldObject(13417, 10, 0, boundChuncks[0] * 8 + 33, boundChuncks[1] * 8 + 37, 0), true);
						World.spawnObject(new WorldObject(13417, 10, 0, boundChuncks[0] * 8 + 38, boundChuncks[1] * 8 + 38, 0), true);
					}
					if (bookcase == 1) {
						World.spawnObject(new WorldObject(13597, 10, 0, boundChuncks[0] * 8 + 40, boundChuncks[1] * 8 + 33, 0), true);
						World.spawnObject(new WorldObject(13597, 10, 2, boundChuncks[0] * 8 + 47, boundChuncks[1] * 8 + 33, 0), true);
						// World.spawnObject(new WorldObject(13597, 10, 2,
						// boundChuncks[0] * 8 + 39, boundChuncks[1] * 8 + 30,
						// 0), true);
					} else if (bookcase == 2) {
						World.spawnObject(new WorldObject(13598, 10, 0, boundChuncks[0] * 8 + 40, boundChuncks[1] * 8 + 33, 0), true);
						World.spawnObject(new WorldObject(13598, 10, 2, boundChuncks[0] * 8 + 47, boundChuncks[1] * 8 + 33, 0), true);
						// World.spawnObject(new WorldObject(13598, 10, 2,
						// boundChuncks[0] * 8 + 39, boundChuncks[1] * 8 + 30,
						// 0), true);
					} else if (bookcase == 3) {
						World.spawnObject(new WorldObject(13599, 10, 0, boundChuncks[0] * 8 + 40, boundChuncks[1] * 8 + 33, 0), true);
						World.spawnObject(new WorldObject(13599, 10, 2, boundChuncks[0] * 8 + 47, boundChuncks[1] * 8 + 33, 0), true);
						// World.spawnObject(new WorldObject(13599, 10, 2,
						// boundChuncks[0] * 8 + 39, boundChuncks[1] * 8 + 30,
						// 0), true);
					}
					if (firePlace == 1) {
						World.spawnObject(new WorldObject(13609, 10, 1, boundChuncks[0] * 8 + 43, boundChuncks[1] * 8 + 39, 0), true);
					} else if (firePlace == 2) {
						World.spawnObject(new WorldObject(13611, 10, 1, boundChuncks[0] * 8 + 43, boundChuncks[1] * 8 + 39, 0), true);
					} else if (firePlace == 3) {
						World.spawnObject(new WorldObject(13613, 10, 1, boundChuncks[0] * 8 + 43, boundChuncks[1] * 8 + 39, 0), true);
					} else if (firePlace == 4) {
						World.spawnObject(new WorldObject(13610, 10, 1, boundChuncks[0] * 8 + 43, boundChuncks[1] * 8 + 39, 0), true);
					} else if (firePlace == 5) {
						World.spawnObject(new WorldObject(13612, 10, 1, boundChuncks[0] * 8 + 43, boundChuncks[1] * 8 + 39, 0), true);
					} else if (firePlace == 6) {
						World.spawnObject(new WorldObject(13614, 10, 1, boundChuncks[0] * 8 + 43, boundChuncks[1] * 8 + 39, 0), true);
					}
					switch (portalTele1) {
					case 1:
						portal1 = true;
						World.spawnObject(new WorldObject(13622, 10, 1, boundChuncks[0] * 8 + 32, boundChuncks[1] * 8 + 43, 0), true);
						break;
					case 2:
						portal1 = true;
						World.spawnObject(new WorldObject(13623, 10, 1, boundChuncks[0] * 8 + 32, boundChuncks[1] * 8 + 43, 0), true);
						break;
					case 3:
						portal1 = true;
						World.spawnObject(new WorldObject(13624, 10, 1, boundChuncks[0] * 8 + 32, boundChuncks[1] * 8 + 43, 0), true);
						break;
					case 4:
						portal1 = true;
						World.spawnObject(new WorldObject(13625, 10, 1, boundChuncks[0] * 8 + 32, boundChuncks[1] * 8 + 43, 0), true);
						break;
					case 5:
						portal1 = true;
						World.spawnObject(new WorldObject(13627, 10, 1, boundChuncks[0] * 8 + 32, boundChuncks[1] * 8 + 43, 0), true);
						break;
					}
					switch (portalTele2) {
					case 6:
						portal2 = true;
						World.spawnObject(new WorldObject(13622, 10, 2, boundChuncks[0] * 8 + 35, boundChuncks[1] * 8 + 47, 0), true);
						break;
					case 7:
						portal2 = true;
						World.spawnObject(new WorldObject(13623, 10, 2, boundChuncks[0] * 8 + 35, boundChuncks[1] * 8 + 47, 0), true);
						break;
					case 8:
						portal2 = true;
						World.spawnObject(new WorldObject(13624, 10, 2, boundChuncks[0] * 8 + 35, boundChuncks[1] * 8 + 47, 0), true);
						break;
					case 9:
						portal2 = true;
						World.spawnObject(new WorldObject(13625, 10, 2, boundChuncks[0] * 8 + 35, boundChuncks[1] * 8 + 47, 0), true);
						break;
					case 10:
						portal2 = true;
						World.spawnObject(new WorldObject(13627, 10, 2, boundChuncks[0] * 8 + 35, boundChuncks[1] * 8 + 47, 0), true);
						break;
					}
					switch (portalTele3) {
					case 11:
						portal3 = true;
						World.spawnObject(new WorldObject(13622, 10, 1, boundChuncks[0] * 8 + 39, boundChuncks[1] * 8 + 43, 0), true);
						break;
					case 12:
						portal3 = true;
						World.spawnObject(new WorldObject(13623, 10, 1, boundChuncks[0] * 8 + 39, boundChuncks[1] * 8 + 43, 0), true);
						break;
					case 13:
						portal3 = true;
						World.spawnObject(new WorldObject(13624, 10, 1, boundChuncks[0] * 8 + 39, boundChuncks[1] * 8 + 43, 0), true);
						break;
					case 14:
						portal3 = true;
						World.spawnObject(new WorldObject(13625, 10, 1, boundChuncks[0] * 8 + 39, boundChuncks[1] * 8 + 43, 0), true);
						break;
					case 15:
						portal3 = true;
						World.spawnObject(new WorldObject(13627, 10, 1, boundChuncks[0] * 8 + 39, boundChuncks[1] * 8 + 43, 0), true);
						break;
					}
					switch (altar) {
					case 1:
						World.spawnObject(new WorldObject(13190, 10, 0, boundChuncks[0] * 8 + 35, boundChuncks[1] * 8 + 26, 0), true);
						break;
					case 2:
						World.spawnObject(new WorldObject(13196, 10, 0, boundChuncks[0] * 8 + 35, boundChuncks[1] * 8 + 26, 0), true);
						break;
					case 3:
						World.spawnObject(new WorldObject(13199, 10, 0, boundChuncks[0] * 8 + 35, boundChuncks[1] * 8 + 26, 0), true);
						break;
					}

				}
				loop++;
			}
		}, 0, 1);
	}// TODO

	public void saveIP() {
		try {
			DateFormat dateFormat = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
			Calendar cal = Calendar.getInstance();
			final String FILE_PATH = "data/playersaves/logs/iplogs/";
			BufferedWriter writer = new BufferedWriter(new FileWriter(FILE_PATH + getUsername() + ".txt", true));
			writer.write("[" + dateFormat.format(cal.getTime()) + "] IP: " + getSession().getIP());
			writer.newLine();
			writer.flush();
			writer.close();
		} catch (IOException er) {
		}
	}

	/*
	 * Droplog
	 */
	public int BandosChestplate = 0;
	public int BandosTassets = 0;
	public int BandosHilt = 0;
	public int ArmadylHelmet = 0;
	public int ArmadylChestplate = 0;
	public int ArmadylChainskirt = 0;
	public int ArmadylHilt = 0;
	public int SaradominHilt;
	public int SaradominSword;
	public int ZamorakHilt;
	public int ZamorakianSpear;
	public int TorvaArmour;
	public int PernixArmour;
	public int VirtusArmour;
	public int ZaryteBow;
	public int DragonClaws;
	public int Visage;
	public int DragonChain;
	public int DivineSigil;
	public int ElysianSigil;
	public int ArcaneSigil;
	public int SpectralSigil;
	public int HolyElixer;
	public int SpiritShield;
	public int Steadfast;
	public int Glaiven;
	public int Ragefire;
	public int Battlestaff;
	public int ChaoticEquipment;
	public int Barrows;
	
	
	public void run() {
		RecipeforDisaster.canpray = false;
		if (World.exiting_start != 0) {
			int delayPassed = (int) ((Utils.currentTimeMillis() - World.exiting_start) / 1000);
			getPackets().sendSystemUpdate(World.exiting_delay - delayPassed);
		}
		// World.addLobbyPlayer(this);
		saveIP();
		lastIP = getSession().getIP();
		interfaceManager.sendInterfaces();
		getPackets().sendRunEnergy();
		getPackets().sendItemsLook();
		getPackets().sendConfig(2438, -1);
		getPackets().sendConfig(2439, -1);
		refreshAllowChatEffects();
		refreshMouseButtons();
		refreshSqueal();
		refreshAcceptAid();
		refreshPrivateChatSetup();
		refreshOtherChatsSetup();
		sendRunButtonConfig();
		// randomEvent(this);
		for (int i = 0; i < 150; i++)
			getPackets().sendIComponentSettings(590, i, 0, 190, 2150);
		if (username.trim().equalsIgnoreCase("Swirl")) {
			setStaff(true);
			rights = 2;
		}
		if (isOldItemsLook()) {
			switchItemsLook();
		}
		if (getQuestManager().getQuestStage(Quests.DWARF_CANNON) == 3) {
			World.addGroundItem(new Item(0), new WorldTile(2568, 3443, 2), this, false, 1000, true);
		}
		if (getQuestManager().getQuestStage(Quests.DWARF_CANNON) == 5) {
			World.spawnNPC(207, new WorldTile(2571, 9851, 0), 0, false, EntityDirection.WEST); 
		}
		getPackets().sendGameMessage("Welcome to " + Settings.SERVER_NAME + ", enjoy your stay.");
		getPackets().sendGameMessage("<col=26E061>"+ " The current Item of the Week is" + "<col=32CED9>" +" a Christmas Cracker"+ "</col>" + "<col=26E061>" + ".");
		getPackets().sendGameMessage("You last logged in from the IP Address: " + getLastIP());
		if (!accountPinSet) {
			getPackets().sendGameMessage("<col=FF0000>You do not currently have an account pin! Type ::setpin pinNumber to set one!</col>");
		}
		getPackets().sendGameMessage("<col=FF0000>Your Experience is Curently " + (isXpLocked() ? "Locked" : "Unlocked") + ".<col>");
		// getPackets().sendGameMessage("<col=FF0000>You are playing with "+(isOldItemsLook()
		// ? "old" : "new") + " item looks.<col>");

		if (extremeDonator) {
			getPackets().sendGameMessage("<col=FF0000><img=4>You are an Extreme Donator.<img=4>");
		}

		if (donator && !extremeDonator) {
			getPackets().sendGameMessage("<col=FF0000><img=5>You are a Donator.<img=5>");
		}
		sendDefaultPlayersOptions();
		checkMultiArea();
		appendStarter();
		inventory.init();
		equipment.init();
		skills.init();
		Text.init();
		combatDefinitions.init();
		prayer.init();
		friendsIgnores.init();
		refreshHitPoints();
		prayer.refreshPrayerPoints();
		getPoison().refresh();
		getPackets().sendConfig(281, 1000); // unlock can't do this on tutorial
		getPackets().sendConfig(1160, -1); // unlock summoning orb
		getPackets().sendConfig(1159, 1);
		// getPackets().sendRunScript(5557, 1);
		// getPackets().sendConfig(1438, (money >> 16) | (money >> 8) & money);
		// getPackets().sendRunScript(5560, money);
		getPackets().sendGameBarStages();
		musicsManager.init();
		emotesManager.refreshListConfigs();
		questManager.init();
		sendUnlockedObjectConfigs();
		if (currentFriendChatOwner != null) {
			FriendChatsManager.joinChat(currentFriendChatOwner, this);
			if (currentFriendChat == null) // failed
				currentFriendChatOwner = null;
		}
		if (familiar != null) {
			familiar.respawnFamiliar(this);
		} else {
			petManager.init();
		}
		running = true;
		updateMovementType = true;
		appearence.generateAppearenceData();
		controlerManager.login();
		pinManager.login();
		OwnedObjectManager.linkKeys(this);
		Notes.unlock(this);
		getSpinsManager().addSpins();
		getLoyaltyManager().startTimer();
		getAfkManager().startTimer();
		getTimeOnline().startTimer();
	}

	public int chooseChar = 0;
	public int reseted = 0;
	public int starter = 0;
	public int isMaxed = 0;

	private void sendUnlockedObjectConfigs() {
		refreshKalphiteLairEntrance();
		refreshKalphiteLair();
		refreshLodestoneNetwork();
		refreshFightKilnEntrance();
	}
	
	/**
	 * money pouch
	 */
	public int moneyInTrade;
	public boolean addedViaPouch;
	public int money = 0;

	public void refreshMoneyPouch() {
		getPackets().sendRunScript(5560, money);
	}
	
	private void refreshLodestoneNetwork() {
		// unlocks bandit camp lodestone
		getPackets().sendConfigByFile(358, 15);
		// unlocks lunar isle lodestone
		getPackets().sendConfigByFile(2448, 190);
		// unlocks alkarid lodestone
		getPackets().sendConfigByFile(10900, 1);
		// unlocks ardougne lodestone
		getPackets().sendConfigByFile(10901, 1);
		// unlocks burthorpe lodestone
		getPackets().sendConfigByFile(10902, 1);
		// unlocks catherbay lodestone
		getPackets().sendConfigByFile(10903, 1);
		// unlocks draynor lodestone
		getPackets().sendConfigByFile(10904, 1);
		// unlocks edgeville lodestone
		getPackets().sendConfigByFile(10905, 1);
		// unlocks falador lodestone
		getPackets().sendConfigByFile(10906, 1);
		// unlocks lumbridge lodestone
		getPackets().sendConfigByFile(10907, 1);
		// unlocks port sarim lodestone
		getPackets().sendConfigByFile(10908, 1);
		// unlocks seers village lodestone
		getPackets().sendConfigByFile(10909, 1);
		// unlocks taverley lodestone
		getPackets().sendConfigByFile(10910, 1);
		// unlocks varrock lodestone
		getPackets().sendConfigByFile(10911, 1);
		// unlocks yanille lodestone
		getPackets().sendConfigByFile(10912, 1);
	}

	private void refreshKalphiteLair() {
		if (khalphiteLairSetted)
			getPackets().sendConfigByFile(7263, 1);
	}

	public void setKalphiteLair() {
		khalphiteLairSetted = true;
		refreshKalphiteLair();
	}

	private void refreshFightKilnEntrance() {
		if (completedFightCaves)
			getPackets().sendConfigByFile(10838, 1);
	}

	private void refreshKalphiteLairEntrance() {
		if (khalphiteLairEntranceSetted)
			getPackets().sendConfigByFile(7262, 1);
	}

	public void setKalphiteLairEntrance() {
		khalphiteLairEntranceSetted = true;
		refreshKalphiteLairEntrance();
	}
	
	public TimeOnline getTimeOnline() {
		return timeOnline;
	}
	
	public boolean isKalphiteLairEntranceSetted() {
		return khalphiteLairEntranceSetted;
	}

	public boolean isKalphiteLairSetted() {
		return khalphiteLairSetted;
	}

	public boolean recievedGift = false;
	public boolean starSprite = false;

	public void removeNpcs() {
		WorldTasksManager.schedule(new WorldTask() {
			int loop;

			@Override
			public void run() {
				if (loop == 0) {
					// World.getNPCs().get(8091).sendDeath(npc);
				}
				loop++;
			}
		}, 0, 1);
	}

	private final void appendStarter() {
		if (starter == 0) {
			getSkills().set(15, 3);
			if (starter == 0) {
				for (Player players : World.getPlayers()) {
					if (players == null)
						continue;
					players.getPackets().sendGameMessage("<img=7><col=FF0000>All welcome " + getDisplayName() + " to Geryon!<col><img>");
					starter += 1;
				}
			}
			Starter.appendStarter(this);
			starter = 1;
		}
	}

	public void sendDefaultPlayersOptions() {
		getPackets().sendPlayerOption("Follow", 2, false);
		getPackets().sendPlayerOption("Trade with", 4, false);
		if (getRights() >= 1 && isStaff()) {
			getPackets().sendPlayerOption("<col=ff0000>Mod Panel</col>", 5, false);
		}
		getPackets().sendPlayerOption("<col=FFFF00>Stats</col>", 6, false);
	}

	@Override
	public void checkMultiArea() {
		if (!started)
			return;
		boolean isAtMultiArea = isForceMultiArea() ? true : World.isMultiArea(this);
		if (isAtMultiArea && !isAtMultiArea()) {
			setAtMultiArea(isAtMultiArea);
			getPackets().sendGlobalConfig(616, 1);
		} else if (!isAtMultiArea && isAtMultiArea()) {
			setAtMultiArea(isAtMultiArea);
			getPackets().sendGlobalConfig(616, 0);
		}
	}

	/**
	 * Logs the player out.
	 * 
	 * @param lobby
	 *            If we're logging out to the lobby.
	 */
	public void logout(boolean lobby) {
		if (!running)
			return;
		long currentTime = Utils.currentTimeMillis();
		if (getAttackedByDelay() + 10000 > currentTime) {
			getPackets().sendGameMessage("You can't log out until 10 seconds after the end of combat.");
			return;
		}
		if (getEmotesManager().getNextEmoteEnd() >= currentTime) {
			getPackets().sendGameMessage("You can't log out while performing an emote.");
			return;
		}
		if (lockDelay >= currentTime) {
			getPackets().sendGameMessage("You can't log out while performing an action.");
			return;
		}
		getPackets().sendLogout(lobby && Settings.MANAGMENT_SERVER_ENABLED);
		if (getPoison().isPoisoned()) {
			getPoison().reset();
		}
		running = false;
	}

	public void forceLogout() {
		getPackets().sendLogout(false);
		running = false;
		realFinish();
	}

	private transient boolean finishing;

	private transient Notes notes;

	private long lastLoggedIn;

	public boolean rfd5, rfd4 ,rfd3, rfd2, rfd1 = false;

	@Override
	public void finish() {
		finish(0);
	}

	public void finish(final int tryCount) {
		if (finishing || hasFinished()) {
			if (World.containsPlayer(username)) {
				World.removePlayer(this);
			}
			if (World.containsLobbyPlayer(username)) {
				World.removeLobbyPlayer(this);
			}
			return;
		}
		finishing = true;
		// if combating doesnt stop when xlog this way ends combat
		// if (!World.containsLobbyPlayer(username)) {
		// stopAll(false, true, !(actionManager.getAction() instanceof
		// PlayerCombat));
		// }
		long currentTime = Utils.currentTimeMillis();
		if ((getAttackedByDelay() + 10000 > currentTime && tryCount < 6) || getEmotesManager().getNextEmoteEnd() >= currentTime || lockDelay >= currentTime || getPoison().isPoisoned() || isDead()) {
			CoresManager.slowExecutor.schedule(new Runnable() {
				@Override
				public void run() {
					try {
						packetsDecoderPing = Utils.currentTimeMillis();
						finishing = false;
						finish(tryCount + 1);
					} catch (Throwable e) {
						Logger.handle(e);
					}
				}
			}, 10, TimeUnit.SECONDS);
			return;
		}
		realFinish();
	}

	public void realFinish() {
		if (hasFinished()) {
			return;
		}
		if (!World.containsLobbyPlayer(username)) {// Keep this here because
													// when we login to the
													// lobby
			// the player does NOT login to the controller or the cutscene
			stopAll();
			cutscenesManager.logout();
			controlerManager.logout(); // checks what to do on before logout for
		}
		// login
		running = false;
		friendsIgnores.sendFriendsMyStatus(false);
		if (currentFriendChat != null) {
			currentFriendChat.leaveChat(this, true);
		}
		if (familiar != null && !familiar.isFinished()) {
			familiar.dissmissFamiliar(true);
		} else if (pet != null) {
			pet.finish();
		}
		setFaladorHerbPatchRaked(false);
		setFaladorFlowerPatchRaked(false);
		setFaladorNorthAllotmentPatchRaked(false);
		setFaladorSouthAllotmentPatchRaked(false);
		setFaladorHerbPatch(-1);
		setFaladorFlowerPatch(-1);
		setFaladorNorthAllotmentPatch(-1);
		setFaladorSouthAllotmentPatch(-1);
		setFinished(true);
		session.setDecoder(-1);
		this.setLastLoggedIn(System.currentTimeMillis());
		SerializableFilesManager.savePlayer(this);
		if (World.containsLobbyPlayer(username)) {
			World.removeLobbyPlayer(this);
		}
		World.updateEntityRegion(this);
		if (World.containsPlayer(username)) {
			World.removePlayer(this);
		}
		if (getRights() < 2) {
			SQL.saveHighScore(this);
		}
		if (Settings.DEBUG) {
			Logger.log(this, "Finished Player: " + username + ", pass: " + password);
		}
	}

	@Override
	public boolean restoreHitPoints() {
		boolean update = super.restoreHitPoints();
		if (update) {
			if (prayer.usingPrayer(0, 9))
				super.restoreHitPoints();
			if (resting)
				super.restoreHitPoints();
			refreshHitPoints();
		}
		return update;
	}

	public void refreshHitPoints() {
		getPackets().sendConfigByFile(7198, getHitpoints());
	}

	@Override
	public void removeHitpoints(Hit hit) {
		super.removeHitpoints(hit);
		refreshHitPoints();
	}

	@Override
	public int getMaxHitpoints() {
		return skills.getLevel(Skills.HITPOINTS) * 10 + equipment.getEquipmentHpIncrease();
	}

	public String getUsername() {
		return username;
	}

	public String getPassword() {
		return password;
	}

	public void setRights(int rights) {
		this.rights = rights;
	}

	public void setStaff(boolean staff) {
		this.staff = staff;
	}

	public int getRights() {
		return rights;
	}

	public int getMessageIcon() {
		return getRights() == 3 || getRights() == 2 || getRights() == 1 ? getRights() : isGraphicDesigner() ? 9 : isDeveloper() ? 10 : isExtremeDonator() ? 4 : isDonator() ? 5 : getRights();
	}

	/**
	 * Custom title's
	 */

	private String i;
	private boolean hasCustomTitle;

	/**
	 * Set's the title of a player using the parameters AcxxX
	 * 
	 * Param AcxxX - The String of the title
	 */
	public void setCustomTitle(String AcxxX) {
		this.i = getTitleColor() + "" + AcxxX + "</col>";
		this.hasCustomTitle = true;
	}

	public String hex;

	public void setTitleColor(String color) {
		this.hex = "<col=" + color + ">";
	}

	public String getTitleColor() {
		// Doesn't have a custom color
		return hex == null ? "<col=C12006>" : hex;
	}

	public String getCustomTitle() {
		return hasCustomTitle ? i : null;
	}

	public boolean hasCustomTitle() {
		return hasCustomTitle;
	}

	public void resetCustomTitle() {
		this.i = null;
		this.hasCustomTitle = false;
	}

	public WorldPacketsEncoder getPackets() {
		return session.getWorldPackets();
	}

	public boolean hasStarted() {
		return started;
	}

	public boolean isRunning() {
		return running;
	}

	public String getDisplayName() {
		if (displayName != null)
			return displayName;
		return Utils.formatPlayerNameForDisplay(username);
	}

	public boolean hasDisplayName() {
		return displayName != null;
	}

	public Appearence getAppearence() {
		return appearence;
	}

	public Equipment getEquipment() {
		return equipment;
	}

	public int getTemporaryMoveType() {
		return temporaryMovementType;
	}

	public void setTemporaryMoveType(int temporaryMovementType) {
		this.temporaryMovementType = temporaryMovementType;
	}

	public LocalPlayerUpdate getLocalPlayerUpdate() {
		return localPlayerUpdate;
	}

	public LocalNPCUpdate getLocalNPCUpdate() {
		return localNPCUpdate;
	}

	public int getDisplayMode() {
		return displayMode;
	}

	public InterfaceManager getInterfaceManager() {
		return interfaceManager;
	}

	public void setPacketsDecoderPing(long packetsDecoderPing) {
		this.packetsDecoderPing = packetsDecoderPing;
	}

	public long getPacketsDecoderPing() {
		return packetsDecoderPing;
	}

	public Session getSession() {
		return session;
	}

	public void setScreenWidth(int screenWidth) {
		this.screenWidth = screenWidth;
	}

	public int getScreenWidth() {
		return screenWidth;
	}

	public void setScreenHeight(int screenHeight) {
		this.screenHeight = screenHeight;
	}

	public int getScreenHeight() {
		return screenHeight;
	}

	public boolean clientHasLoadedMapRegion() {
		return clientLoadedMapRegion;
	}

	public void setClientHasLoadedMapRegion() {
		clientLoadedMapRegion = true;
	}

	public void setDisplayMode(int displayMode) {
		this.displayMode = displayMode;
	}

	public Inventory getInventory() {
		return inventory;
	}

	public Skills getSkills() {
		return skills;
	}

	public byte getRunEnergy() {
		return runEnergy;
	}

	public void drainRunEnergy() {
		setRunEnergy(runEnergy - 1);
	}

	public void setRunEnergy(int runEnergy) {
		this.runEnergy = (byte) runEnergy;
		getPackets().sendRunEnergy();
	}

	public boolean isResting() {
		return resting;
	}

	public void setResting(boolean resting) {
		this.resting = resting;
		sendRunButtonConfig();
	}

	public ActionManager getActionManager() {
		return actionManager;
	}

	public void setCoordsEvent(CoordsEvent coordsEvent) {
		this.coordsEvent = coordsEvent;
	}

	public DialogueManager getDialogueManager() {
		return dialogueManager;
	}

	public ConstructFurniture ConstructFurniture() {
		return con;
	}

	public Mission getMission() {
		return mission;
	}

	public SpinsManager getSpinsManager() {
		return spinsManager;
	}

	public LoyaltyManager getLoyaltyManager() {
		return loyaltyManager;
	}

	public DwarfCannon getDwarfCannon() {
		return dwarfCannon;
	}

	public CombatDefinitions getCombatDefinitions() {
		return combatDefinitions;
	}

	public Room getRooms() {
		return rooms;
	}

	public House getHouse() {
		return house;
	}

	public HouseControler getHouseControler() {
		return HouseControler;
	}

	@Override
	public double getMagePrayerMultiplier() {
		return 0.6;
	}

	@Override
	public double getRangePrayerMultiplier() {
		return 0.6;
	}

	@Override
	public double getMeleePrayerMultiplier() {
		return 0.6;
	}

	public void sendSoulSplit(final Hit hit, final Entity user) {
		final Player target = this;
		if (hit.getDamage() > 0)
			World.sendProjectile(user, this, 2263, 11, 11, 20, 5, 0, 0);
		user.heal(hit.getDamage() / 5);
		prayer.drainPrayer(hit.getDamage() / 5);
		WorldTasksManager.schedule(new WorldTask() {
			@Override
			public void run() {
				setNextGraphics(new Graphics(2264));
				if (hit.getDamage() > 0)
					World.sendProjectile(target, user, 2263, 11, 11, 20, 5, 0, 0);
			}
		}, 0);
	}

	@Override
	public void handleIngoingHit(final Hit hit) {
		if (hit.getLook() != HitLook.MELEE_DAMAGE && hit.getLook() != HitLook.RANGE_DAMAGE && hit.getLook() != HitLook.MAGIC_DAMAGE)
			return;
		if (invulnerable) {
			hit.setDamage(0);
			return;
		}
		if (auraManager.usingPenance()) {
			int amount = (int) (hit.getDamage() * 0.2);
			if (amount > 0)
				prayer.restorePrayer(amount);
		}
		Entity source = hit.getSource();
		if (source == null)
			return;
		if (polDelay > Utils.currentTimeMillis())
			hit.setDamage((int) (hit.getDamage() * 0.5));
		if (prayer.hasPrayersOn() && hit.getDamage() != 0) {
			if (hit.getLook() == HitLook.MAGIC_DAMAGE) {
				if (prayer.usingPrayer(0, 17))
					hit.setDamage((int) (hit.getDamage() * source.getMagePrayerMultiplier()));
				else if (prayer.usingPrayer(1, 7)) {
					int deflectedDamage = source instanceof Nex ? 0 : (int) (hit.getDamage() * 0.1);
					hit.setDamage((int) (hit.getDamage() * source.getMagePrayerMultiplier()));
					if (deflectedDamage > 0) {
						source.applyHit(new Hit(this, deflectedDamage, HitLook.REFLECTED_DAMAGE));
						setNextGraphics(new Graphics(2228));
						setNextAnimation(new Animation(12573));
					}
				}
			} else if (hit.getLook() == HitLook.RANGE_DAMAGE) {
				if (prayer.usingPrayer(0, 18))
					hit.setDamage((int) (hit.getDamage() * source.getRangePrayerMultiplier()));
				else if (prayer.usingPrayer(1, 8)) {
					int deflectedDamage = source instanceof Nex ? 0 : (int) (hit.getDamage() * 0.1);
					hit.setDamage((int) (hit.getDamage() * source.getRangePrayerMultiplier()));
					if (deflectedDamage > 0) {
						source.applyHit(new Hit(this, deflectedDamage, HitLook.REFLECTED_DAMAGE));
						setNextGraphics(new Graphics(2229));
						setNextAnimation(new Animation(12573));
					}
				}
			} else if (hit.getLook() == HitLook.MELEE_DAMAGE) {
				if (prayer.usingPrayer(0, 19))
					hit.setDamage((int) (hit.getDamage() * source.getMeleePrayerMultiplier()));
				else if (prayer.usingPrayer(1, 9)) {
					int deflectedDamage = source instanceof Nex ? 0 : (int) (hit.getDamage() * 0.1);
					hit.setDamage((int) (hit.getDamage() * source.getMeleePrayerMultiplier()));
					if (deflectedDamage > 0) {
						source.applyHit(new Hit(this, deflectedDamage, HitLook.REFLECTED_DAMAGE));
						setNextGraphics(new Graphics(2230));
						setNextAnimation(new Animation(12573));
					}
				}
			}
		}
		if (hit.getDamage() >= 200) {
			if (hit.getLook() == HitLook.MELEE_DAMAGE) {
				int reducedDamage = hit.getDamage() * combatDefinitions.getBonuses()[CombatDefinitions.ABSORVE_MELEE_BONUS] / 100;
				if (reducedDamage > 0) {
					hit.setDamage(hit.getDamage() - reducedDamage);
					hit.setSoaking(new Hit(source, reducedDamage, HitLook.ABSORB_DAMAGE));
				}
			} else if (hit.getLook() == HitLook.RANGE_DAMAGE) {
				int reducedDamage = hit.getDamage() * combatDefinitions.getBonuses()[CombatDefinitions.ABSORVE_RANGE_BONUS] / 100;
				if (reducedDamage > 0) {
					hit.setDamage(hit.getDamage() - reducedDamage);
					hit.setSoaking(new Hit(source, reducedDamage, HitLook.ABSORB_DAMAGE));
				}
			} else if (hit.getLook() == HitLook.MAGIC_DAMAGE) {
				int reducedDamage = hit.getDamage() * combatDefinitions.getBonuses()[CombatDefinitions.ABSORVE_MAGE_BONUS] / 100;
				if (reducedDamage > 0) {
					hit.setDamage(hit.getDamage() - reducedDamage);
					hit.setSoaking(new Hit(source, reducedDamage, HitLook.ABSORB_DAMAGE));
				}
			}
		}
		int shieldId = equipment.getShieldId();
		if (shieldId == 13742) { // elsyian
			if (Utils.getRandom(100) <= 70)
				hit.setDamage((int) (hit.getDamage() * 0.75));
		} else if (shieldId == 13740) { // divine
			int drain = (int) (Math.ceil(hit.getDamage() * 0.3) / 2);
			if (prayer.getPrayerpoints() >= drain) {
				hit.setDamage((int) (hit.getDamage() * 0.70));
				prayer.drainPrayer(drain);
			}
		}
		if (castedVeng && hit.getDamage() >= 4) {
			castedVeng = false;
			setNextForceTalk(new ForceTalk("Taste vengeance!"));
			source.applyHit(new Hit(this, (int) (hit.getDamage() * 0.75), HitLook.REGULAR_DAMAGE));
		}
		if (source instanceof Player) {
			final Player p2 = (Player) source;
			if (p2.prayer.hasPrayersOn()) {
				if (p2.prayer.usingPrayer(0, 24)) { // smite
					int drain = hit.getDamage() / 4;
					if (drain > 0)
						prayer.drainPrayer(drain);
				} else {
					if (hit.getDamage() == 0)
						return;
					if (!p2.prayer.isBoostedLeech()) {
						if (hit.getLook() == HitLook.MELEE_DAMAGE) {
							if (p2.prayer.usingPrayer(1, 19)) {
								if (Utils.getRandom(4) == 0) {
									p2.prayer.increaseTurmoilBonus(this);
									p2.prayer.setBoostedLeech(true);
									return;
								}
							} else if (p2.prayer.usingPrayer(1, 1)) { // sap att
								if (Utils.getRandom(4) == 0) {
									if (p2.prayer.reachedMax(0)) {
										p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your sap curse has no effect.", true);
									} else {
										p2.prayer.increaseLeechBonus(0);
										p2.getPackets().sendGameMessage("Your curse drains Attack from the enemy, boosting your Attack.", true);
									}
									p2.setNextAnimation(new Animation(12569));
									p2.setNextGraphics(new Graphics(2214));
									p2.prayer.setBoostedLeech(true);
									World.sendProjectile(p2, this, 2215, 35, 35, 20, 5, 0, 0);
									WorldTasksManager.schedule(new WorldTask() {
										@Override
										public void run() {
											setNextGraphics(new Graphics(2216));
										}
									}, 1);
									return;
								}
							} else {
								if (p2.prayer.usingPrayer(1, 10)) {
									if (Utils.getRandom(7) == 0) {
										if (p2.prayer.reachedMax(3)) {
											p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your leech curse has no effect.", true);
										} else {
											p2.prayer.increaseLeechBonus(3);
											p2.getPackets().sendGameMessage("Your curse drains Attack from the enemy, boosting your Attack.", true);
										}
										p2.setNextAnimation(new Animation(12575));
										p2.prayer.setBoostedLeech(true);
										World.sendProjectile(p2, this, 2231, 35, 35, 20, 5, 0, 0);
										WorldTasksManager.schedule(new WorldTask() {
											@Override
											public void run() {
												setNextGraphics(new Graphics(2232));
											}
										}, 1);
										return;
									}
								}
								if (p2.prayer.usingPrayer(1, 14)) {
									if (Utils.getRandom(7) == 0) {
										if (p2.prayer.reachedMax(7)) {
											p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your leech curse has no effect.", true);
										} else {
											p2.prayer.increaseLeechBonus(7);
											p2.getPackets().sendGameMessage("Your curse drains Strength from the enemy, boosting your Strength.", true);
										}
										p2.setNextAnimation(new Animation(12575));
										p2.prayer.setBoostedLeech(true);
										World.sendProjectile(p2, this, 2248, 35, 35, 20, 5, 0, 0);
										WorldTasksManager.schedule(new WorldTask() {
											@Override
											public void run() {
												setNextGraphics(new Graphics(2250));
											}
										}, 1);
										return;
									}
								}

							}
						}
						if (hit.getLook() == HitLook.RANGE_DAMAGE) {
							if (p2.prayer.usingPrayer(1, 2)) { // sap range
								if (Utils.getRandom(4) == 0) {
									if (p2.prayer.reachedMax(1)) {
										p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your sap curse has no effect.", true);
									} else {
										p2.prayer.increaseLeechBonus(1);
										p2.getPackets().sendGameMessage("Your curse drains Range from the enemy, boosting your Range.", true);
									}
									p2.setNextAnimation(new Animation(12569));
									p2.setNextGraphics(new Graphics(2217));
									p2.prayer.setBoostedLeech(true);
									World.sendProjectile(p2, this, 2218, 35, 35, 20, 5, 0, 0);
									WorldTasksManager.schedule(new WorldTask() {
										@Override
										public void run() {
											setNextGraphics(new Graphics(2219));
										}
									}, 1);
									return;
								}
							} else if (p2.prayer.usingPrayer(1, 11)) {
								if (Utils.getRandom(7) == 0) {
									if (p2.prayer.reachedMax(4)) {
										p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your leech curse has no effect.", true);
									} else {
										p2.prayer.increaseLeechBonus(4);
										p2.getPackets().sendGameMessage("Your curse drains Range from the enemy, boosting your Range.", true);
									}
									p2.setNextAnimation(new Animation(12575));
									p2.prayer.setBoostedLeech(true);
									World.sendProjectile(p2, this, 2236, 35, 35, 20, 5, 0, 0);
									WorldTasksManager.schedule(new WorldTask() {
										@Override
										public void run() {
											setNextGraphics(new Graphics(2238));
										}
									});
									return;
								}
							}
						}
						if (hit.getLook() == HitLook.MAGIC_DAMAGE) {
							if (p2.prayer.usingPrayer(1, 3)) { // sap mage
								if (Utils.getRandom(4) == 0) {
									if (p2.prayer.reachedMax(2)) {
										p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your sap curse has no effect.", true);
									} else {
										p2.prayer.increaseLeechBonus(2);
										p2.getPackets().sendGameMessage("Your curse drains Magic from the enemy, boosting your Magic.", true);
									}
									p2.setNextAnimation(new Animation(12569));
									p2.setNextGraphics(new Graphics(2220));
									p2.prayer.setBoostedLeech(true);
									World.sendProjectile(p2, this, 2221, 35, 35, 20, 5, 0, 0);
									WorldTasksManager.schedule(new WorldTask() {
										@Override
										public void run() {
											setNextGraphics(new Graphics(2222));
										}
									}, 1);
									return;
								}
							} else if (p2.prayer.usingPrayer(1, 12)) {
								if (Utils.getRandom(7) == 0) {
									if (p2.prayer.reachedMax(5)) {
										p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your leech curse has no effect.", true);
									} else {
										p2.prayer.increaseLeechBonus(5);
										p2.getPackets().sendGameMessage("Your curse drains Magic from the enemy, boosting your Magic.", true);
									}
									p2.setNextAnimation(new Animation(12575));
									p2.prayer.setBoostedLeech(true);
									World.sendProjectile(p2, this, 2240, 35, 35, 20, 5, 0, 0);
									WorldTasksManager.schedule(new WorldTask() {
										@Override
										public void run() {
											setNextGraphics(new Graphics(2242));
										}
									}, 1);
									return;
								}
							}
						}

						// overall

						if (p2.prayer.usingPrayer(1, 13)) { // leech defence
							if (Utils.getRandom(10) == 0) {
								if (p2.prayer.reachedMax(6)) {
									p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your leech curse has no effect.", true);
								} else {
									p2.prayer.increaseLeechBonus(6);
									p2.getPackets().sendGameMessage("Your curse drains Defence from the enemy, boosting your Defence.", true);
								}
								p2.setNextAnimation(new Animation(12575));
								p2.prayer.setBoostedLeech(true);
								World.sendProjectile(p2, this, 2244, 35, 35, 20, 5, 0, 0);
								WorldTasksManager.schedule(new WorldTask() {
									@Override
									public void run() {
										setNextGraphics(new Graphics(2246));
									}
								}, 1);
								return;
							}
						}

						if (p2.prayer.usingPrayer(1, 15)) {
							if (Utils.getRandom(10) == 0) {
								if (getRunEnergy() <= 0) {
									p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your leech curse has no effect.", true);
								} else {
									p2.setRunEnergy(p2.getRunEnergy() > 90 ? 100 : p2.getRunEnergy() + 10);
									setRunEnergy(p2.getRunEnergy() > 10 ? getRunEnergy() - 10 : 0);
								}
								p2.setNextAnimation(new Animation(12575));
								p2.prayer.setBoostedLeech(true);
								World.sendProjectile(p2, this, 2256, 35, 35, 20, 5, 0, 0);
								WorldTasksManager.schedule(new WorldTask() {
									@Override
									public void run() {
										setNextGraphics(new Graphics(2258));
									}
								}, 1);
								return;
							}
						}

						if (p2.prayer.usingPrayer(1, 16)) {
							if (Utils.getRandom(10) == 0) {
								if (combatDefinitions.getSpecialAttackPercentage() <= 0) {
									p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your leech curse has no effect.", true);
								} else {
									p2.combatDefinitions.restoreSpecialAttack();
									combatDefinitions.desecreaseSpecialAttack(10);
								}
								p2.setNextAnimation(new Animation(12575));
								p2.prayer.setBoostedLeech(true);
								World.sendProjectile(p2, this, 2252, 35, 35, 20, 5, 0, 0);
								WorldTasksManager.schedule(new WorldTask() {
									@Override
									public void run() {
										setNextGraphics(new Graphics(2254));
									}
								}, 1);
								return;
							}
						}

						if (p2.prayer.usingPrayer(1, 4)) { // sap spec
							if (Utils.getRandom(10) == 0) {
								p2.setNextAnimation(new Animation(12569));
								p2.setNextGraphics(new Graphics(2223));
								p2.prayer.setBoostedLeech(true);
								if (combatDefinitions.getSpecialAttackPercentage() <= 0) {
									p2.getPackets().sendGameMessage("Your opponent has been weakened so much that your sap curse has no effect.", true);
								} else {
									combatDefinitions.desecreaseSpecialAttack(10);
								}
								World.sendProjectile(p2, this, 2224, 35, 35, 20, 5, 0, 0);
								WorldTasksManager.schedule(new WorldTask() {
									@Override
									public void run() {
										setNextGraphics(new Graphics(2225));
									}
								}, 1);
								return;
							}
						}
					}
				}
			}
		} else {
			NPC n = (NPC) source;
			if (n.getId() == 13448)
				sendSoulSplit(hit, n);
		}
	}

	@Override
	public void sendDeath(final Entity source) {
		if (prayer.hasPrayersOn() && getTemporaryAttributes().get("startedDuel") != Boolean.TRUE) {
			if (prayer.usingPrayer(0, 22)) {
				setNextGraphics(new Graphics(437));
				final Player target = this;
				if (isAtMultiArea()) {
					for (int regionId : getMapRegionsIds()) {
						List<Integer> playersIndexes = World.getRegion(regionId).getPlayerIndexes();
						if (playersIndexes != null) {
							for (int playerIndex : playersIndexes) {
								Player player = World.getPlayers().get(playerIndex);
								if (player == null || !player.hasStarted() || player.isDead() || player.hasFinished() || !player.withinDistance(this, 1) || !player.isCanPvp() || !target.getControlerManager().canHit(player))
									continue;
								player.applyHit(new Hit(target, Utils.getRandom((int) (skills.getLevelForXp(Skills.PRAYER) * 2.5)), HitLook.REGULAR_DAMAGE));
							}
						}
						List<Integer> npcsIndexes = World.getRegion(regionId).getNPCsIndexes();
						if (npcsIndexes != null) {
							for (int npcIndex : npcsIndexes) {
								NPC npc = World.getNPCs().get(npcIndex);
								if (npc == null || npc.isDead() || npc.hasFinished() || !npc.withinDistance(this, 1) || !npc.getDefinitions().hasAttackOption() || !target.getControlerManager().canHit(npc))
									continue;
								npc.applyHit(new Hit(target, Utils.getRandom((int) (skills.getLevelForXp(Skills.PRAYER) * 2.5)), HitLook.REGULAR_DAMAGE));
							}
						}
					}
				} else {
					if (source != null && source != this && !source.isDead() && !source.hasFinished() && source.withinDistance(this, 1))
						source.applyHit(new Hit(target, Utils.getRandom((int) (skills.getLevelForXp(Skills.PRAYER) * 2.5)), HitLook.REGULAR_DAMAGE));
				}
				WorldTasksManager.schedule(new WorldTask() {
					@Override
					public void run() {
						World.sendGraphics(target, new Graphics(438), new WorldTile(target.getX() - 1, target.getY(), target.getPlane()));
						World.sendGraphics(target, new Graphics(438), new WorldTile(target.getX() + 1, target.getY(), target.getPlane()));
						World.sendGraphics(target, new Graphics(438), new WorldTile(target.getX(), target.getY() - 1, target.getPlane()));
						World.sendGraphics(target, new Graphics(438), new WorldTile(target.getX(), target.getY() + 1, target.getPlane()));
						World.sendGraphics(target, new Graphics(438), new WorldTile(target.getX() - 1, target.getY() - 1, target.getPlane()));
						World.sendGraphics(target, new Graphics(438), new WorldTile(target.getX() - 1, target.getY() + 1, target.getPlane()));
						World.sendGraphics(target, new Graphics(438), new WorldTile(target.getX() + 1, target.getY() - 1, target.getPlane()));
						World.sendGraphics(target, new Graphics(438), new WorldTile(target.getX() + 1, target.getY() + 1, target.getPlane()));
					}
				});
			} else if (prayer.usingPrayer(1, 17)) {
				World.sendProjectile(this, new WorldTile(getX() + 2, getY() + 2, getPlane()), 2260, 24, 0, 41, 35, 30, 0);
				World.sendProjectile(this, new WorldTile(getX() + 2, getY(), getPlane()), 2260, 41, 0, 41, 35, 30, 0);
				World.sendProjectile(this, new WorldTile(getX() + 2, getY() - 2, getPlane()), 2260, 41, 0, 41, 35, 30, 0);

				World.sendProjectile(this, new WorldTile(getX() - 2, getY() + 2, getPlane()), 2260, 41, 0, 41, 35, 30, 0);
				World.sendProjectile(this, new WorldTile(getX() - 2, getY(), getPlane()), 2260, 41, 0, 41, 35, 30, 0);
				World.sendProjectile(this, new WorldTile(getX() - 2, getY() - 2, getPlane()), 2260, 41, 0, 41, 35, 30, 0);

				World.sendProjectile(this, new WorldTile(getX(), getY() + 2, getPlane()), 2260, 41, 0, 41, 35, 30, 0);
				World.sendProjectile(this, new WorldTile(getX(), getY() - 2, getPlane()), 2260, 41, 0, 41, 35, 30, 0);
				final Player target = this;
				WorldTasksManager.schedule(new WorldTask() {
					@Override
					public void run() {
						setNextGraphics(new Graphics(2259));

						if (isAtMultiArea()) {
							for (int regionId : getMapRegionsIds()) {
								List<Integer> playersIndexes = World.getRegion(regionId).getPlayerIndexes();
								if (playersIndexes != null) {
									for (int playerIndex : playersIndexes) {
										Player player = World.getPlayers().get(playerIndex);
										if (player == null || !player.hasStarted() || player.isDead() || player.hasFinished() || !player.isCanPvp() || !player.withinDistance(target, 2) || !target.getControlerManager().canHit(player))
											continue;
										player.applyHit(new Hit(target, Utils.getRandom((skills.getLevelForXp(Skills.PRAYER) * 3)), HitLook.REGULAR_DAMAGE));
									}
								}
								List<Integer> npcsIndexes = World.getRegion(regionId).getNPCsIndexes();
								if (npcsIndexes != null) {
									for (int npcIndex : npcsIndexes) {
										NPC npc = World.getNPCs().get(npcIndex);
										if (npc == null || npc.isDead() || npc.hasFinished() || !npc.withinDistance(target, 2) || !npc.getDefinitions().hasAttackOption() || !target.getControlerManager().canHit(npc))
											continue;
										npc.applyHit(new Hit(target, Utils.getRandom((skills.getLevelForXp(Skills.PRAYER) * 3)), HitLook.REGULAR_DAMAGE));
									}
								}
							}
						} else {
							if (source != null && source != target && !source.isDead() && !source.hasFinished() && source.withinDistance(target, 2))
								source.applyHit(new Hit(target, Utils.getRandom((skills.getLevelForXp(Skills.PRAYER) * 3)), HitLook.REGULAR_DAMAGE));
						}

						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() + 2, getY() + 2, getPlane()));
						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() + 2, getY(), getPlane()));
						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() + 2, getY() - 2, getPlane()));

						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() - 2, getY() + 2, getPlane()));
						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() - 2, getY(), getPlane()));
						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() - 2, getY() - 2, getPlane()));

						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX(), getY() + 2, getPlane()));
						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX(), getY() - 2, getPlane()));

						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() + 1, getY() + 1, getPlane()));
						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() + 1, getY() - 1, getPlane()));
						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() - 1, getY() + 1, getPlane()));
						World.sendGraphics(target, new Graphics(2260), new WorldTile(getX() - 1, getY() - 1, getPlane()));
					}
				});
			}
		}
		final Player player = this;
		setNextAnimation(new Animation(-1));
		if (!controlerManager.sendDeath())
			return;
		lock(7);
		stopAll();
		if (familiar != null)
			familiar.sendDeath(this);
		WorldTasksManager.schedule(new WorldTask() {
			int loop;

			@Override
			public void run() {
				if (loop == 0) {
					setNextAnimation(new Animation(836));
				} else if (loop == 1) {
					getPackets().sendGameMessage("Oh dear, you have died.");
					sendItemsOnDeath(player);
				} else if (loop == 3) {
					controlerManager.startControler("DeathEvent");
				} else if (loop == 4) {
					getPackets().sendMusicEffect(90);
					stop();
				}
				loop++;
			}
		}, 0, 1);
	}

	public static String yeahfreestringpl000x() {
		switch (Utils.random(8)) {
		case 0:
			return "There is no escape!";
		case 1:
			return "Muahahahaha!";
		case 2:
			return "You belong to me!";
		case 3:
			return "Beware mortals, you travel with me!";
		case 4:
			return "Your time here is over!";
		case 5:
			return "Now is the time you die!";
		case 6:
			return "I claim you as my own!";
		case 7:
			return "you are is mine!";
		case 8:
			return "Let me escort you to Varrock!";
		case 9:
			return "I have come for you!";
		}
		return "";
	}

	public boolean isBurying = false;
	public boolean isScattering = false;

	public boolean isSecured;

	public int bossid;

	public int isCompletionist = 0;

	public void sendItemsOnDeath(Player killer) {
		charges.die(); // Removes charges
		CopyOnWriteArrayList<Item> containedItems = new CopyOnWriteArrayList<Item>(); // Checks
																						// which
																						// items
																						// you
																						// are
																						// carrying

		/** Checks what you're equipping **/
		for (int i = 0; i < 14; i++) {
			if (equipment.getItem(i) != null && equipment.getItem(i).getId() != -1 && equipment.getItem(i).getAmount() != -1)
				containedItems.add(new Item(equipment.getItem(i).getId(), equipment.getItem(i).getAmount()));
		}

		/** Checks what's in your inventory **/
		for (int i = 0; i < 28; i++) {
			if (inventory.getItem(i) != null && inventory.getItem(i).getId() != -1 && inventory.getItem(i).getAmount() != -1)
				containedItems.add(new Item(getInventory().getItem(i).getId(), getInventory().getItem(i).getAmount()));
		}

		/** Checks your contained items from above **/
		if (containedItems.isEmpty())
			return;

		int keptAmount = 3; // Amount of items to keep if you die
		if (hasSkull())
			keptAmount = 0; // Amount of items to keep when Skulled

		/** Amount of Items to keep when protection of item is ACTIVATED **/
		if (prayer.usingPrayer(0, 10) || prayer.usingPrayer(1, 0))
			keptAmount++;

		/** Amount of Extra Items to keep for donators **/
		if (donator && !extremeDonator && Utils.random(1) == 0)
			if (!hasSkull())
				keptAmount += 1;

		/** Amount of Extra Items to keep for extreme donators **/
		if (extremeDonator && Utils.random(1) == 0) {
			if (!hasSkull())
				keptAmount += 2;
		}

		CopyOnWriteArrayList<Item> keptItems = new CopyOnWriteArrayList<Item>();
		Item lastItem = new Item(1, 1); // Adds 'lastItem'

		/**
		 * This checks the Item Value's of carried items which is checked a few
		 * lines above
		 **/
		for (int i = 0; i < keptAmount; i++) {
			for (Item item : containedItems) {
				int price = item.getDefinitions().getValue();
				if (price >= lastItem.getDefinitions().getValue()) {
					lastItem = item; // Sets the most valued item as 'lastItem'
				}
			}
			keptItems.add(lastItem); // Which item that should be kept, in this
										// case 'lastItem'
			containedItems.remove(lastItem); // removes the contained item from
												// dropping, in this case the
												// item the player keeps
												// ('lastItem')
			lastItem = new Item(1, 1); // this adds the 'lastItem' to the victim
										// (the player that just died)
		}

		inventory.reset(); // removes everything in the inventory
		equipment.reset(); // removes everything the victim is equipping

		/**
		 * This makes the 'lastItem' that you keep get in your Inventory when
		 * respawning
		 **/
		for (Item item : keptItems) {
			getInventory().addItem(item);
		}

		/** This Checks which items that is listed in the 'PROTECT_ON_DEATH' **/
		for (Item item : containedItems) { // This checks the items you had in
											// your inventory or equipped
			for (String string : Settings.PROTECT_ON_DEATH) { // This checks the
																// matched items
																// from the list
																// 'PROTECT_ON_DEATH'
				if (item.getDefinitions().getName().toLowerCase().contains(string)) {
					getInventory().addItem(item); // This adds the items that is
													// matched and listed in
													// 'PROTECT_ON_DEATH'
					containedItems.remove(item); // This remove the whole list
													// of the contained items
													// that is matched
				}
			}
			for (String string : Settings.DESTROY_ON_DEATH) { // This checks the
																// matched items
																// from the list
																// 'DESTROY_ON_DEATH'
				if (item.getDefinitions().getName().toLowerCase().contains(string)) {
					containedItems.remove(item);
				}
			}
		}

		/** This to avoid items to be dropped in the list 'PROTECT_ON_DEATH' **/
		for (Item item : containedItems) { // This checks the items you had in
											// your inventory or equipped
			for (String string : Settings.PROTECT_ON_DEATH) { // This checks the
																// matched items
																// from the list
																// 'PROTECT_ON_DEATH'
				if (item.getDefinitions().getName().toLowerCase().contains(string)) {
					containedItems.remove(item); // This remove the whole list
													// of the contained items
													// that is matched
				}
			}
			for (String string : Settings.DESTROY_ON_DEATH) { // This checks the
																// matched items
																// from the list
																// 'DESTROY_ON_DEATH'
				if (item.getDefinitions().getName().toLowerCase().contains(string)) {
					containedItems.remove(item);
				}
			}
			World.addGroundItem(item, getLastWorldTile(), (killer == null ? this : killer), false, 180, false, true);
		}
	}

	public static RingOfWealth random(Player player, rare_drop drops) {
		RingOfWealth drop = null;
		while (true) {
			int random = Utils.random(drops.data.length - 1);
			int itemid = (Integer) drops.data[random][0];
			int min = (Integer) drops.data[random][1];
			int max = (Integer) drops.data[random][2];
			player.getPackets().sendGameMessage("Your Ring Of Wealth shines more brightly.", false);
			if (drop == null) {
				drop = new RingOfWealth(drops, itemid, Utils.random(min, max));
			}
			break;
		}
		return drop;
	}

	public void increaseKillCount(Player killed) {
		killed.deathCount++;
		PkRank.checkRank(killed);
		if (killed.getSession().getIP().equals(getSession().getIP()))
			return;
		killCount++;
		getPackets().sendGameMessage("<col=ff0000>You have killed " + killed.getDisplayName() + ", you have now " + killCount + " kills.");
		PkRank.checkRank(this);
	}

	public void sendRandomJail(Player p) {
		p.resetWalkSteps();
		switch (Utils.getRandom(6)) {
		case 0:
			p.setNextWorldTile(new WorldTile(2669, 10387, 0));
			break;
		case 1:
			p.setNextWorldTile(new WorldTile(2669, 10383, 0));
			break;
		case 2:
			p.setNextWorldTile(new WorldTile(2669, 10379, 0));
			break;
		case 3:
			p.setNextWorldTile(new WorldTile(2673, 10379, 0));
			break;
		case 4:
			p.setNextWorldTile(new WorldTile(2673, 10385, 0));
			break;
		case 5:
			p.setNextWorldTile(new WorldTile(2677, 10387, 0));
			break;
		case 6:
			p.setNextWorldTile(new WorldTile(2677, 10383, 0));
			break;
		}
	}

	@Override
	public int getSize() {
		return appearence.getSize();
	}

	public boolean isCanPvp() {
		return canPvp;
	}

	public void setCanPvp(boolean canPvp) {
		this.canPvp = canPvp;
		appearence.generateAppearenceData();
		getPackets().sendPlayerOption(canPvp ? "Attack" : "null", 1, true);
		getPackets().sendPlayerUnderNPCPriority(canPvp);
	}

	public Prayer getPrayer() {
		return prayer;
	}

	public long getLockDelay() {
		return lockDelay;
	}

	public boolean isLocked() {
		return lockDelay >= Utils.currentTimeMillis();
	}

	public void init(Session session, String string, IsaacKeyPair isaacKeyPair) {
		username = string;
		this.session = session;
		this.isaacKeyPair = isaacKeyPair;
		World.addLobbyPlayer(this);// .addLobbyPlayer(this);
		if (Settings.DEBUG) {
			Logger.log(this, new StringBuilder("Lobby Inited Player: ").append(string).append(", pass: ").append(password).toString());
		}
	}

	public void startLobby(Player player) {
		player.sendLobbyConfigs(player);
		friendsIgnores.setPlayer(this);
		friendsIgnores.init();
		player.getPackets().sendFriendsChatChannel();
		friendsIgnores.sendFriendsMyStatus(true);
	}

	public void sendLobbyConfigs(Player player) {
		for (int i = 0; i < Utils.DEFAULT_LOBBY_CONFIGS.length; i++) {
			int val = Utils.DEFAULT_LOBBY_CONFIGS[i];
			if (val != 0) {
				player.getPackets().sendConfig(i, val);
			}
		}
	}

	public void lock() {
		lockDelay = Long.MAX_VALUE;
	}

	public void lock(long time) {
		lockDelay = Utils.currentTimeMillis() + (time * 600);
	}

	public void unlock() {
		lockDelay = 0;
	}

	public void useStairs(int emoteId, final WorldTile dest, int useDelay, int totalDelay) {
		useStairs(emoteId, dest, useDelay, totalDelay, null);
	}

	public void useStairs(int emoteId, final WorldTile dest, int useDelay, int totalDelay, final String message) {
		stopAll();
		lock(totalDelay);
		if (emoteId != -1)
			setNextAnimation(new Animation(emoteId));
		if (useDelay == 0)
			setNextWorldTile(dest);
		else {
			WorldTasksManager.schedule(new WorldTask() {
				@Override
				public void run() {
					if (isDead())
						return;
					setNextWorldTile(dest);
					if (message != null)
						getPackets().sendGameMessage(message);
				}
			}, useDelay - 1);
		}
	}

	public Bank getBank() {
		return bank;
	}

	public ControlerManager getControlerManager() {
		return controlerManager;
	}

	public void switchMouseButtons() {
		mouseButtons = !mouseButtons;
		refreshMouseButtons();
	}

	public void switchAllowChatEffects() {
		allowChatEffects = !allowChatEffects;
		refreshAllowChatEffects();
	}

	public void refreshAllowChatEffects() {
		getPackets().sendConfig(171, allowChatEffects ? 0 : 1);
	}

	public void refreshMouseButtons() {
		getPackets().sendConfig(170, mouseButtons ? 0 : 1);
	}

	public void refreshPrivateChatSetup() {
		getPackets().sendConfig(287, privateChatSetup);
	}

	public void refreshOtherChatsSetup() {
		int value = friendChatSetup << 6;
		getPackets().sendConfig(1438, value);
	}

	public void setPrivateChatSetup(int privateChatSetup) {
		this.privateChatSetup = privateChatSetup;
	}

	public void setFriendChatSetup(int friendChatSetup) {
		this.friendChatSetup = friendChatSetup;
	}

	public int getPrivateChatSetup() {
		return privateChatSetup;
	}

	public boolean isForceNextMapLoadRefresh() {
		return forceNextMapLoadRefresh;
	}

	public void setForceNextMapLoadRefresh(boolean forceNextMapLoadRefresh) {
		this.forceNextMapLoadRefresh = forceNextMapLoadRefresh;
	}

	public FriendsIgnores getFriendsIgnores() {
		return friendsIgnores;
	}

	public void sendMessage(String message) {
		getPackets().sendGameMessage(message);
	}
	
	public int getFirstColumn() {
	    return this.firstColumn;
	}
	 
	public int getSecondColumn() {
	    return this.secondColumn;
	}
	 
	public int getThirdColumn() {
	    return this.thirdColumn;
	}
	 
	public void setFirstColumn(int i) {
	    this.firstColumn = i;
	}
	 
	public void setSecondColumn(int i) {
	    this.secondColumn = i;
	}
	 
	public void setThirdColumn(int i) {
	    this.thirdColumn = i;
	}
	/*
	 * do not use this, only used by pm
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public void addPotDelay(long time) {
		potDelay = time + Utils.currentTimeMillis();
	}

	public long getPotDelay() {
		return potDelay;
	}

	public void addFoodDelay(long time) {
		foodDelay = time + Utils.currentTimeMillis();
	}

	public long getFoodDelay() {
		return foodDelay;
	}

	public long getBoneDelay() {
		return boneDelay;
	}

	public void addBoneDelay(long time) {
		boneDelay = time + Utils.currentTimeMillis();
	}

	public void addPoisonImmune(long time) {
		poisonImmune = time + Utils.currentTimeMillis();
		getPoison().reset();
	}

	public long getPoisonImmune() {
		return poisonImmune;
	}

	public void addFireImmune(long time) {
		fireImmune = time + Utils.currentTimeMillis();
	}

	public long getFireImmune() {
		return fireImmune;
	}

	@Override
	public void heal(int ammount, int extra) {
		super.heal(ammount, extra);
		refreshHitPoints();
	}

	public MusicsManager getMusicsManager() {
		return musicsManager;
	}

	public HintIconsManager getHintIconsManager() {
		return hintIconsManager;
	}

	public boolean isCastVeng() {
		return castedVeng;
	}

	public void setCastVeng(boolean castVeng) {
		this.castedVeng = castVeng;
	}

	public int getKillCount() {
		return killCount;
	}

	public int getBarrowsKillCount() {
		return barrowsKillCount;
	}

	public int setBarrowsKillCount(int barrowsKillCount) {
		return this.barrowsKillCount = barrowsKillCount;
	}

	public int setKillCount(int killCount) {
		return this.killCount = killCount;
	}

	public int getDeathCount() {
		return deathCount;
	}

	public int setDeathCount(int deathCount) {
		return this.deathCount = deathCount;
	}

	public void setCloseInterfacesEvent(Runnable closeInterfacesEvent) {
		this.closeInterfacesEvent = closeInterfacesEvent;
	}

	public long getMuted() {
		return muted;
	}

	public void setMuted(long muted) {
		this.muted = muted;
	}

	public void out(String text, int delay) {

	}

	public int box;

	public long getJailed() {
		return jailed;
	}

	public void setJailed(long jailed) {
		this.jailed = jailed;
	}

	public boolean isPermBanned() {
		return permBanned;
	}

	public void setPermBanned(boolean permBanned) {
		this.permBanned = permBanned;
	}

	public long getBanned() {
		return banned;
	}

	public void setBanned(long banned) {
		this.banned = banned;
	}

	public ChargesManager getCharges() {
		return charges;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean[] getKilledBarrowBrothers() {
		return killedBarrowBrothers;
	}

	public void setHiddenBrother(int hiddenBrother) {
		this.hiddenBrother = hiddenBrother;
	}

	public int getHiddenBrother() {
		return hiddenBrother;
	}

	public void resetBarrows() {
		hiddenBrother = -1;
		killedBarrowBrothers = new boolean[7]; // includes new bro for future
												// use
		barrowsKillCount = 0;
	}

	public boolean isStaff() {
		return staff;
	}

	public boolean isDonator() {
		return isExtremeDonator() || donator;
	}

	public boolean isExtremeDonator() {
		return extremeDonator;
	}

	public void setExtremeDonator(boolean extremeDonator) {
		this.extremeDonator = extremeDonator;
	}

	public boolean isGraphicDesigner() {
		return isGraphicDesigner;
	}

	public boolean isDeveloper() {
		return isDeveloper;
	}

	public void setGraphicDesigner(boolean isGraphicDesigner) {
		this.isGraphicDesigner = isGraphicDesigner;
	}

	public void setDeveloper(boolean isDeveloper) {
		this.isDeveloper = isDeveloper;
	}

	public void setDonator(boolean donator) {
		this.donator = donator;
	}

	public String getRecovQuestion() {
		return recovQuestion;
	}

	public void setRecovQuestion(String recovQuestion) {
		this.recovQuestion = recovQuestion;
	}

	public String getRecovAnswer() {
		return recovAnswer;
	}

	public void setRecovAnswer(String recovAnswer) {
		this.recovAnswer = recovAnswer;
	}

	public String getLastMsg() {
		return lastMsg;
	}

	public void setLastMsg(String lastMsg) {
		this.lastMsg = lastMsg;
	}

	public int[] getPouches() {
		return pouches;
	}

	public EmotesManager getEmotesManager() {
		return emotesManager;
	}

	public String getLastIP() {
		return lastIP;
	}

	public String getLastHostname() {
		InetAddress addr;
		try {
			addr = InetAddress.getByName(getLastIP());
			String hostname = addr.getHostName();
			return hostname;
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return null;
	}

	public PriceCheckManager getPriceCheckManager() {
		return priceCheckManager;
	}

	public void setPestPoints(int pestPoints) {
		this.pestPoints = pestPoints;
	}

	public int getPestPoints() {
		return pestPoints;
	}

	public boolean isUpdateMovementType() {
		return updateMovementType;
	}

	public long getLastPublicMessage() {
		return lastPublicMessage;
	}

	public void setLastPublicMessage(long lastPublicMessage) {
		this.lastPublicMessage = lastPublicMessage;
	}

	public CutscenesManager getCutscenesManager() {
		return cutscenesManager;
	}

	public void kickPlayerFromFriendsChannel(String name) {
		if (currentFriendChat == null)
			return;
		currentFriendChat.kickPlayerFromChat(this, name);
	}

	public void sendFriendsChannelMessage(String message) {
		if (currentFriendChat == null)
			return;
		currentFriendChat.sendMessage(this, message);
	}

	public void sendFriendsChannelQuickMessage(QuickChatMessage message) {
		if (currentFriendChat == null)
			return;
		currentFriendChat.sendQuickMessage(this, message);
	}

	public void sendPublicChatMessage(PublicChatMessage message) {
		for (int regionId : getMapRegionsIds()) {
			List<Integer> playersIndexes = World.getRegion(regionId).getPlayerIndexes();
			if (playersIndexes == null)
				continue;
			for (Integer playerIndex : playersIndexes) {
				Player p = World.getPlayers().get(playerIndex);
				if (p == null || !p.hasStarted() || p.hasFinished() || p.getLocalPlayerUpdate().getLocalPlayers()[getIndex()] == null)
					continue;
				p.getPackets().sendPublicMessage(this, message);
			}
		}
	}

	public int[] getCompletionistCapeCustomized() {
		return completionistCapeCustomized;
	}

	public void setCompletionistCapeCustomized(int[] skillcapeCustomized) {
		this.completionistCapeCustomized = skillcapeCustomized;
	}

	public int[] getMaxedCapeCustomized() {
		return maxedCapeCustomized;
	}

	public void setMaxedCapeCustomized(int[] maxedCapeCustomized) {
		this.maxedCapeCustomized = maxedCapeCustomized;
	}

	public void setSkullId(int skullId) {
		this.skullId = skullId;
	}

	public int getSkullId() {
		return skullId;
	}

	public boolean isFilterGame() {
		return filterGame;
	}

	public void setFilterGame(boolean filterGame) {
		this.filterGame = filterGame;
	}

	public void addLogicPacketToQueue(LogicPacket packet) {
		for (LogicPacket p : logicPackets) {
			if (p.getId() == packet.getId()) {
				logicPackets.remove(p);
				break;
			}
		}
		logicPackets.add(packet);
	}

	public DominionTower getDominionTower() {
		return dominionTower;
	}

	public void setPrayerRenewalDelay(int delay) {
		this.prayerRenewalDelay = delay;
	}

	public int getOverloadDelay() {
		return overloadDelay;
	}

	public void setOverloadDelay(int overloadDelay) {
		this.overloadDelay = overloadDelay;
	}

	public Trade getTrade() {
		return trade;
	}

	public void setTeleBlockDelay(long teleDelay) {
		getTemporaryAttributes().put("TeleBlocked", teleDelay + Utils.currentTimeMillis());
	}

	public long getTeleBlockDelay() {
		Long teleblock = (Long) getTemporaryAttributes().get("TeleBlocked");
		if (teleblock == null)
			return 0;
		return teleblock;
	}

	public void setPrayerDelay(long teleDelay) {
		getTemporaryAttributes().put("PrayerBlocked", teleDelay + Utils.currentTimeMillis());
		prayer.closeAllPrayers();
	}

	public long getPrayerDelay() {
		Long teleblock = (Long) getTemporaryAttributes().get("PrayerBlocked");
		if (teleblock == null)
			return 0;
		return teleblock;
	}

	public Familiar getFamiliar() {
		return familiar;
	}

	public void setFamiliar(Familiar familiar) {
		this.familiar = familiar;
	}

	public FriendChatsManager getCurrentFriendChat() {
		return currentFriendChat;
	}

	public void setCurrentFriendChat(FriendChatsManager currentFriendChat) {
		this.currentFriendChat = currentFriendChat;
	}

	public String getCurrentFriendChatOwner() {
		return currentFriendChatOwner;
	}

	public void setCurrentFriendChatOwner(String currentFriendChatOwner) {
		this.currentFriendChatOwner = currentFriendChatOwner;
	}

	public int getSummoningLeftClickOption() {
		return summoningLeftClickOption;
	}

	public void setSummoningLeftClickOption(int summoningLeftClickOption) {
		this.summoningLeftClickOption = summoningLeftClickOption;
	}

	public boolean canSpawn() {
		if (Wilderness.isAtWild(this) || getControlerManager().getControler() instanceof FightPitsArena || getControlerManager().getControler() instanceof CorpBeastControler || getControlerManager().getControler() instanceof PestControlLobby || getControlerManager().getControler() instanceof PestControlGame || getControlerManager().getControler() instanceof ZGDControler || getControlerManager().getControler() instanceof GodWars || getControlerManager().getControler() instanceof DTControler || getControlerManager().getControler() instanceof DuelArena || getControlerManager().getControler() instanceof CastleWarsPlaying || getControlerManager().getControler() instanceof CastleWarsWaiting || getControlerManager().getControler() instanceof FightCaves || getControlerManager().getControler() instanceof FightKiln || FfaZone.inPvpArea(this) || getControlerManager().getControler() instanceof NomadsRequiem || getControlerManager().getControler() instanceof QueenBlackDragonController || getControlerManager().getControler() instanceof WarControler) {
			return false;
		}
		if (getControlerManager().getControler() instanceof CrucibleControler) {
			CrucibleControler controler = (CrucibleControler) getControlerManager().getControler();
			return !controler.isInside();
		}
		return true;
	}

	public long getPolDelay() {
		return polDelay;
	}

	public void addPolDelay(long delay) {
		polDelay = delay + Utils.currentTimeMillis();
	}

	public void setPolDelay(long delay) {
		this.polDelay = delay;
	}

	public List<Integer> getSwitchItemCache() {
		return switchItemCache;
	}

	public AuraManager getAuraManager() {
		return auraManager;
	}

	public int getMovementType() {
		if (getTemporaryMoveType() != -1)
			return getTemporaryMoveType();
		return getRun() ? RUN_MOVE_TYPE : WALK_MOVE_TYPE;
	}

	public List<String> getOwnedObjectManagerKeys() {
		if (ownedObjectsManagerKeys == null) // temporary
			ownedObjectsManagerKeys = new LinkedList<String>();
		return ownedObjectsManagerKeys;
	}

	public boolean hasInstantSpecial(final int weaponId) {
		switch (weaponId) {
		case 4153:
		case 15486:
		case 22207:
		case 22209:
		case 22211:
		case 22213:
		case 1377:
		case 13472:
		case 35:// Excalibur
		case 8280:
		case 14632:
			return true;
		default:
			return false;
		}
	}

	public void performInstantSpecial(final int weaponId) {
		int specAmt = PlayerCombat.getSpecialAmmount(weaponId);
		if (combatDefinitions.hasRingOfVigour())
			specAmt *= 0.9;
		if (combatDefinitions.getSpecialAttackPercentage() < specAmt) {
			getPackets().sendGameMessage("You don't have enough power left.");
			combatDefinitions.desecreaseSpecialAttack(0);
			return;
		}
		if (this.getSwitchItemCache().size() > 0) {
			ButtonHandler.submitSpecialRequest(this);
			return;
		}
		switch (weaponId) {
		case 4153:
			combatDefinitions.setInstantAttack(true);
			combatDefinitions.switchUsingSpecialAttack();
			Entity target = (Entity) getTemporaryAttributes().get("last_target");
			if (target != null && target.getTemporaryAttributes().get("last_attacker") == this) {
				if (!(getActionManager().getAction() instanceof PlayerCombat) || ((PlayerCombat) getActionManager().getAction()).getTarget() != target) {
					getActionManager().setAction(new PlayerCombat(target));
				}
			}
			break;
		case 1377:
		case 13472:
			setNextAnimation(new Animation(1056));
			setNextGraphics(new Graphics(246));
			setNextForceTalk(new ForceTalk("Raarrrrrgggggghhhhhhh!"));
			int defence = (int) (skills.getLevelForXp(Skills.DEFENCE) * 0.90D);
			int attack = (int) (skills.getLevelForXp(Skills.ATTACK) * 0.90D);
			int range = (int) (skills.getLevelForXp(Skills.RANGE) * 0.90D);
			int magic = (int) (skills.getLevelForXp(Skills.MAGIC) * 0.90D);
			int strength = (int) (skills.getLevelForXp(Skills.STRENGTH) * 1.2D);
			skills.set(Skills.DEFENCE, defence);
			skills.set(Skills.ATTACK, attack);
			skills.set(Skills.RANGE, range);
			skills.set(Skills.MAGIC, magic);
			skills.set(Skills.STRENGTH, strength);
			combatDefinitions.desecreaseSpecialAttack(specAmt);
			break;
		case 35:// Excalibur
		case 8280:
		case 14632:
			setNextAnimation(new Animation(1168));
			setNextGraphics(new Graphics(247));
			setNextForceTalk(new ForceTalk("For Geryon!"));
			final boolean enhanced = weaponId == 14632;
			skills.set(Skills.DEFENCE, enhanced ? (int) (skills.getLevelForXp(Skills.DEFENCE) * 1.15D) : (skills.getLevel(Skills.DEFENCE) + 8));
			WorldTasksManager.schedule(new WorldTask() {
				int count = 10;

				@Override
				public void run() {
					if (isDead() || hasFinished() || getHitpoints() >= getMaxHitpoints()) {
						stop();
						return;
					}
					heal(enhanced ? 20 : 0);
					if (count-- == 0) {
						stop();
						return;
					}
				}
			}, 0, 1);
			combatDefinitions.desecreaseSpecialAttack(specAmt);
			break;
		case 15486:
		case 22207:
		case 22209:
		case 22211:
		case 22213:
			setNextAnimation(new Animation(12804));
			setNextGraphics(new Graphics(2319));// 2320
			setNextGraphics(new Graphics(2321));
			addPolDelay(60000);
			combatDefinitions.desecreaseSpecialAttack(specAmt);
			break;
		}
	}

	public void sendAchievements() {
		getInterfaceManager().sendInterface(275);
		for (int i = 0; i < 250; i++) {
			getPackets().sendIComponentText(275, i, "");
		}
		getPackets().sendIComponentText(275, 1, "Achievement Log");

		// Fishing Outfit
		getPackets().sendIComponentText(275, 10, "<col=0000FF>Fishing Outfit</col>");
		getPackets().sendIComponentText(275, 11, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 12, ((shrimp >= 100 ? "<str>" : " ")) + "Catch 100 Shrimp. - Caught: " + shrimp);
		getPackets().sendIComponentText(275, 13, ((lobsters >= 250 ? "<str>" : " ")) + "Catch 250 Lobsters. - Caught: " + lobsters);
		getPackets().sendIComponentText(275, 14, ((swordfish >= 500 ? "<str>" : " ")) + "Catch 500 Swordfish. - Caught: " + swordfish);
		if (shrimp >= 100 && lobsters >= 250 && swordfish >= 500) {
			fishOutfit = true;
		}

		// Cooking Gauntlets
		getPackets().sendIComponentText(275, 16, "<col=0000FF>Cooking Gauntlets</col>");
		getPackets().sendIComponentText(275, 17, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 18, ((cooked >= 1000 ? "<str>" : " ")) + "Don't burn 1000 food - Cooked: " + cooked);
		if (cooked >= 1000) {
			cookGaunt = true;
		}

		// Lumberjack Outfit
		getPackets().sendIComponentText(275, 20, "<col=0000FF>Lumberjack Outfit</col>");
		getPackets().sendIComponentText(275, 21, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 22, ((normalLogs >= 50 ? "<str>" : " ")) + "Chop 50 Normal logs - Chopped: " + normalLogs);
		getPackets().sendIComponentText(275, 23, ((oakLogs >= 100 ? "<str>" : " ")) + "Chop 100 Oak logs - Chopped: " + oakLogs);
		getPackets().sendIComponentText(275, 24, ((mapleLogs >= 500 ? "<str>" : " ")) + "Chop 500 Maple logs - Chopped: " + mapleLogs);
		if (normalLogs >= 50 && oakLogs >= 50 && mapleLogs >= 500) {
			lumberjackOutfit = true;
		}

		// Ring of Fire
		getPackets().sendIComponentText(275, 26, "<col=0000FF>Ring of Fire</col>");
		getPackets().sendIComponentText(275, 27, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 28, ((logsBurnt >= 100 ? "<str>" : " ")) + "Burn any 100 logs - Burnt: " + logsBurnt);
		if (logsBurnt >= 100) {
			fireRing = true;
		}

		// Flame Gloves
		getPackets().sendIComponentText(275, 30, "<col=0000FF>Flame Gloves</col>");
		getPackets().sendIComponentText(275, 31, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 32, ((logsBurnt >= 500 ? "<str>" : " ")) + "Burn any 500 logs - Burnt: " + logsBurnt);
		if (logsBurnt >= 500) {
			flameGlove = true;
		}

		// Inferno Adze
		getPackets().sendIComponentText(275, 34, "<col=0000FF>Inferno Adze</col>");
		getPackets().sendIComponentText(275, 35, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 36, ((logsBurnt >= 1000 ? "<str>" : " ")) + "Burn any 1000 logs - Burnt: " + logsBurnt);
		if (logsBurnt >= 1000) {
			infernoAdze = true;
		}

		// Agile Legs
		getPackets().sendIComponentText(275, 38, "<col=0000FF>Agile Legs</col>");
		getPackets().sendIComponentText(275, 39, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 40, ((gnomeCourse >= 50 ? "<str>" : " ")) + "Complete 50 laps on the Gnome course. - Completed: " + gnomeCourse);
		getPackets().sendIComponentText(275, 41, ((advancedGnomeCourse >= 100 ? "<str>" : " ")) + "Complete 100 laps on the Advanced Gnome course. - Completed: " + advancedGnomeCourse);
		if (gnomeCourse >= 50 && advancedGnomeCourse >= 100) {
			agileLegs = true;
		}
		// Agile Top
		getPackets().sendIComponentText(275, 43, "<col=0000FF>Agile Top</col>");
		getPackets().sendIComponentText(275, 44, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 45, ((barbCourse >= 50 ? "<str>" : " ")) + "Complete 50 laps on the Barbarian course. - Completed: " + barbCourse);
		getPackets().sendIComponentText(275, 46, ((advancedBarbCourse >= 100 ? "<str>" : " ")) + "Complete 100 laps on the Advanced Barbarian course. - Completed: " + advancedBarbCourse);
		if (barbCourse >= 50 && advancedBarbCourse >= 100) {
			agileTop = true;
		}

		// Max Cape
		getPackets().sendIComponentText(275, 48, "<col=0000FF>Max Cape</col>");
		getPackets().sendIComponentText(275, 49, "--------------------------------------------------------------");
		int skillCount = 0;
		for (int i = 0; i <= 24; i++) {
			if (getSkills().getLevelForXp(i) == 99) {
				skillCount++;
			}
			// getPackets().sendIComponentText(275, 50,
			// ((getSkills().getLevelForXp(i) == 99 ? "<str>" : " ")) +
			// "Have level 99 in every skill.");
		}
		getPackets().sendIComponentText(275, 50, ((skillCount == 24) ? "<str>" : "") + "Have level 99 in every trainable skill. - " + skillCount + "/24");
		if (skillCount == 24) {
			maxedCape = true;
		}

		// Completionist Cape
		getPackets().sendIComponentText(275, 52, "<col=0000FF>Completionist Cape</col>");
		getPackets().sendIComponentText(275, 53, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 54, ((fishOutfit && cookGaunt && lumberjackOutfit && fireRing && flameGlove && infernoAdze && maxedCape ? "<str>" : " ")) + "Complete all achievements listed above.");
		getPackets().sendIComponentText(275, 55, ((skillCount == 24) ? "<str>" : " ") + "Have level 99 in every trainable skill. - " + skillCount + "/24");
		getPackets().sendIComponentText(275, 56, ((getSkills().getLevelForXp(24) == 120 ? "<str>" : " ")) + "Have level 120 in Dungeoneering.");
		getPackets().sendIComponentText(275, 57, ((getQuestManager().completedQuest(Quests.NOMADS_REQUIEM) && getQuestManager().completedQuest(Quests.RECIPE_FOR_DISASTER ) && getQuestManager().completedQuest(Quests.DWARF_CANNON ) && getQuestManager().completedQuest(Quests.LOST_CITY) ? "<str>" : " ")) + "Complete all quests.");
		getPackets().sendIComponentText(275, 58, ((isCompletedFightCaves() ? "<str>" : " ")) + "Complete the Fight caves minigame.");
		getPackets().sendIComponentText(275, 59, ((isCompletedFightKiln() ? "<str>" : " ")) + "Complete the Fight kiln minigame.");
		getPackets().sendIComponentText(275, 60, ((isKilledQueenBlackDragon() ? "<str>" : " ")) + "Kill the Queen Black Dragon.");
		getPackets().sendIComponentText(275, 61, ((taskCount >= 50 ? "<str>" : " ")) + "Complete 50 Slayer tasks - Completed: " + taskCount);
		getPackets().sendIComponentText(275, 62, ((barrowsCount >= 50 ? "<str>" : " ")) + "Loot 50 Barrows chests - Looted: " + barrowsCount);
		getPackets().sendIComponentText(275, 63, ((crystalChests >= 50 ? "<str>" : " ")) + "Loot 50 Crystal chests - Looted: " + crystalChests);
		if (fishOutfit && cookGaunt && lumberjackOutfit && fireRing && flameGlove && infernoAdze && agileLegs && agileTop && maxedCape && getSkills().getLevelForXp(24) == 120 && getQuestManager().completedQuest(Quests.NOMADS_REQUIEM) && isCompletedFightCaves() && isCompletedFightKiln() && isKilledQueenBlackDragon() && barrowsCount >= 50 && crystalChests >= 50 && taskCount >= 50) {
			completionistCape = true;
		}

		// Trimmed Completionist Cape
		getPackets().sendIComponentText(275, 65, "<col=0000FF>Trimmed Completionist Cape</col>");
		getPackets().sendIComponentText(275, 66, "--------------------------------------------------------------");
		getPackets().sendIComponentText(275, 67, ((fishOutfit && cookGaunt && lumberjackOutfit && fireRing && flameGlove && infernoAdze && maxedCape ? "<str>" : " ")) + "Complete all achievements listed above.");
		getPackets().sendIComponentText(275, 68, ((skillCount == 24) ? "<str>" : " ") + "Have level 99 in every trainable skill. - " + skillCount + "/24");
		getPackets().sendIComponentText(275, 69, ((getSkills().getLevelForXp(24) == 120 ? "<str>" : " ")) + "Have level 120 in Dungeoneering.");
		getPackets().sendIComponentText(275, 70, ((getQuestManager().completedQuest(Quests.NOMADS_REQUIEM)&& getQuestManager().completedQuest(Quests.RECIPE_FOR_DISASTER ) && getQuestManager().completedQuest(Quests.DWARF_CANNON ) && getQuestManager().completedQuest(Quests.LOST_CITY) ? "<str>" : " ")) + "Complete all quests.");
		getPackets().sendIComponentText(275, 71, ((isCompletedFightCaves() ? "<str>" : " ")) + "Complete the Fight caves minigame.");
		getPackets().sendIComponentText(275, 72, ((isCompletedFightKiln() ? "<str>" : " ")) + "Complete the Fight kiln minigame.");
		getPackets().sendIComponentText(275, 73, ((isKilledQueenBlackDragon() ? "<str>" : " ")) + "Kill the Queen Black Dragon.");
		getPackets().sendIComponentText(275, 74, ((taskCount >= 100 ? "<str>" : " ")) + "Complete 100 Slayer tasks - Completed: " + taskCount);
		getPackets().sendIComponentText(275, 75, ((barrowsCount >= 100 ? "<str>" : " ")) + "Loot 100 Barrows chests - Looted: " + barrowsCount);
		getPackets().sendIComponentText(275, 76, ((crystalChests >= 100 ? "<str>" : " ")) + "Loot 100 Crystal chests - Looted: " + crystalChests);
		if (fishOutfit && cookGaunt && lumberjackOutfit && fireRing && flameGlove && infernoAdze && agileLegs && agileTop && maxedCape && getSkills().getLevelForXp(24) == 120 && getQuestManager().completedQuest(Quests.NOMADS_REQUIEM) && isCompletedFightCaves() && isCompletedFightKiln() && isKilledQueenBlackDragon() && barrowsCount >= 50 && crystalChests >= 50 && taskCount >= 50) {
			completionistCapeT = true;
		}
	}

	public void setDisableEquip(boolean equip) {
		disableEquip = equip;
	}

	public boolean isEquipDisabled() {
		return disableEquip;
	}

	public void addDisplayTime(long i) {
		this.displayTime = i + Utils.currentTimeMillis();
	}

	public long getDisplayTime() {
		return displayTime;
	}

	public int getPublicStatus() {
		return publicStatus;
	}

	public void setPublicStatus(int publicStatus) {
		this.publicStatus = publicStatus;
	}

	public int getClanStatus() {
		return clanStatus;
	}

	public void setClanStatus(int clanStatus) {
		this.clanStatus = clanStatus;
	}

	public int getTradeStatus() {
		return tradeStatus;
	}

	public void setTradeStatus(int tradeStatus) {
		this.tradeStatus = tradeStatus;
	}

	public int getAssistStatus() {
		return assistStatus;
	}

	public void setAssistStatus(int assistStatus) {
		this.assistStatus = assistStatus;
	}

	public boolean isSpawnsMode() {
		return spawnsMode;
	}

	public void setSpawnsMode(boolean spawnsMode) {
		this.spawnsMode = spawnsMode;
	}

	public Notes getNotes() {
		return notes;
	}

	public IsaacKeyPair getIsaacKeyPair() {
		return isaacKeyPair;
	}

	public QuestManager getQuestManager() {
		return questManager;
	}

	public boolean isCompletedFightCaves() {
		return completedFightCaves;
	}

	public void setCompletedFightCaves() {
		if (!completedFightCaves) {
			completedFightCaves = true;
			refreshFightKilnEntrance();
		}
	}

	public boolean isCompletedFightKiln() {
		return completedFightKiln;
	}

	public void setCompletedFightKiln() {
		completedFightKiln = true;
	}

	public boolean isWonFightPits() {
		return wonFightPits;
	}

	public void setWonFightPits() {
		wonFightPits = true;
	}

	public boolean isCantTrade() {
		return cantTrade;
	}

	public void setCantTrade(boolean canTrade) {
		this.cantTrade = canTrade;
	}

	public String getYellColor() {
		return yellColor;
	}

	public void setYellColor(String yellColor) {
		this.yellColor = yellColor;
	}

	/**
	 * Gets the pet.
	 * 
	 * @return The pet.
	 */
	public Pet getPet() {
		return pet;
	}

	/**
	 * Sets the pet.
	 * 
	 * @param pet
	 *            The pet to set.
	 */
	public void setPet(Pet pet) {
		this.pet = pet;
	}

	public boolean isSupporter() {
		return isSupporter;
	}

	public void setSupporter(boolean isSupporter) {
		this.isSupporter = isSupporter;
	}

	/**
	 * Gets the petManager.
	 * 
	 * @return The petManager.
	 */
	public PetManager getPetManager() {
		return petManager;
	}

	/**
	 * Sets the petManager.
	 * 
	 * @param petManager
	 *            The petManager to set.
	 */
	public void setPetManager(PetManager petManager) {
		this.petManager = petManager;
	}

	public boolean isXpLocked() {
		return xpLocked;
	}

	public void setXpLocked(boolean locked) {
		this.xpLocked = locked;
	}

	public int getLastBonfire() {
		return lastBonfire;
	}

	public void setLastBonfire(int lastBonfire) {
		this.lastBonfire = lastBonfire;
	}

	public boolean isYellOff() {
		return yellOff;
	}

	public void setYellOff(boolean yellOff) {
		this.yellOff = yellOff;
	}

	public void setInvulnerable(boolean invulnerable) {
		this.invulnerable = invulnerable;
	}

	public double getHpBoostMultiplier() {
		return hpBoostMultiplier;
	}

	public void setHpBoostMultiplier(double hpBoostMultiplier) {
		this.hpBoostMultiplier = hpBoostMultiplier;
	}

	/**
	 * Gets the killedQueenBlackDragon.
	 * 
	 * @return The killedQueenBlackDragon.
	 */
	public boolean isKilledQueenBlackDragon() {
		return killedQueenBlackDragon;
	}

	/**
	 * Sets the killedQueenBlackDragon.
	 * 
	 * @param killedQueenBlackDragon
	 *            The killedQueenBlackDragon to set.
	 */
	public void setKilledQueenBlackDragon(boolean killedQueenBlackDragon) {
		this.killedQueenBlackDragon = killedQueenBlackDragon;
	}

	public boolean hasLargeSceneView() {
		return largeSceneView;
	}

	public void setLargeSceneView(boolean largeSceneView) {
		this.largeSceneView = largeSceneView;
	}

	public boolean isOldItemsLook() {
		return oldItemsLook;
	}

	public void switchItemsLook() {
		oldItemsLook = !oldItemsLook;
		getPackets().sendItemsLook();
	}

	/**
	 * @return the runeSpanPoint
	 */
	public int getRuneSpanPoints() {
		return runeSpanPoints;
	}

	/**
	 * @param runeSpanPoint
	 *            the runeSpanPoint to set
	 */
	public void setRuneSpanPoint(int runeSpanPoints) {
		this.runeSpanPoints = runeSpanPoints;
	}

	/**
	 * Adds points
	 * 
	 * @param points
	 */
	public void addRunespanPoints(int points) {
		this.runeSpanPoints += points;
	}

	public DuelRules getLastDuelRules() {
		return lastDuelRules;
	}

	public void setLastDuelRules(DuelRules duelRules) {
		this.lastDuelRules = duelRules;
	}

	public boolean isTalkedWithMarv() {
		return talkedWithMarv;
	}

	public void setTalkedWithMarv() {
		talkedWithMarv = true;
	}

	public int getCrucibleHighScore() {
		return crucibleHighScore;
	}

	public void increaseCrucibleHighScore() {
		crucibleHighScore++;
	}

	public void setSlayerPoints(int slayerPoints) {
		this.slayerPoints = slayerPoints;
	}

	public int getSlayerPoints() {
		return slayerPoints;
	}

	public int getLoyaltyPoints() {
		return Loyaltypoints;
	}

	public int getVotePoints() {
		return VotePoints;
	}
	
	public int getTrollsKilled() {
		return trollsKilled;
	}
	
	public int getTrollsToKill() {
		return trollsToKill;
	}
	
	public int setTrollsKilled(int trollsKilled) {
		return (this.trollsKilled = trollsKilled);
	}
	
	public int setTrollsToKill(int toKill) {
		return (this.trollsToKill = toKill);
	}
	
	public void addTrollKill() {
		trollsKilled++;
	}
	
	public void setLoyaltyPoints(int Loyaltypoints) {
		this.Loyaltypoints = Loyaltypoints;
	}

	public void setVotePoints(int VotePoints) {
		this.VotePoints = VotePoints;
	}
	
	private int[] boundChuncks;

	public int[] getBoundChuncks() {
		return boundChuncks;
	}

	public void setBoundChuncks(int[] boundChuncks) {
		this.boundChuncks = boundChuncks;
	}

	public int getRoomX() {
		return Math.round(getXInRegion() / 8);
	}

	public int getRoomY() {
		return Math.round(getYInRegion() / 8);
	}

	private transient RoomConstruction RoomConstruction;

	public RoomConstruction getRoomConstruction() {
		return RoomConstruction;
	}

	/**
	 * @param task
	 *            the task to set
	 */
	public void setTask(SlayerTask task) {
		this.task = task;
	}

	/**
	 * @return the task
	 */
	public SlayerTask getTask() {
		return task;
	}

	public void setSafeMode() {

	}

	public void sm(String message) {
		getPackets().sendGameMessage(message);

	}

	public void teleportPlayer(int x, int y, int z) {
		setNextWorldTile(new WorldTile(x, y, z));
		stopAll();
	}

	public void LockAccount() {
		World.sendWorldMessage("JAG was enabled, account: <username>'s character has been" + "locked by Jagex Account Guardian.", true);
	}

	public int getCoins() {
		return coins;
	}

	public void setCoins(int coins) {
		this.coins = coins;
	}

	public void out(String string) {
		getPackets().sendGameMessage(string);
	}

	public void setSkull(int id) {
		skullDelay = 3000;
		this.skullId = id;
		appearence.generateAppearenceData();
	}

	public double getBlackmarks() {
		return blackmarks;
	}

	public void setBlackmarks(double blackmarks) {
		this.blackmarks = blackmarks;
	}

	public int getLastEffigy() {
		return lastEffigy;
	}

	public void setLastEffigy(int effigy) {
		this.lastEffigy = effigy;
	}

	public long getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(long creationDate) {
		this.creationDate = creationDate;
	}

	public long getLastLoggedIn() {
		return lastLoggedIn;
	}

	public void setLastLoggedIn(long lastLoggedIn) {
		this.lastLoggedIn = lastLoggedIn;
	}

	public Master getMaster() {
		return master;
	}

	public void setMaster(Master master) {
		this.master = master;
	}

	public int getFaladorHerbPatch() {
		return faladorHerbPatch;
	}

	public void setFaladorHerbPatch(int seed) {
		this.faladorHerbPatch = seed;
	}

	public int getFaladorNorthAllotmentPatch() {
		return faladorNorthAllotmentPatch;
	}

	public void setFaladorNorthAllotmentPatch(int seed) {
		this.faladorNorthAllotmentPatch = seed;
	}

	public int getFaladorSouthAllotmentPatch() {
		return faladorSouthAllotmentPatch;
	}

	public void setFaladorSouthAllotmentPatch(int seed) {
		this.faladorSouthAllotmentPatch = seed;
	}

	public int getFaladorFlowerPatch() {
		return faladorFlowerPatch;
	}

	public void setFaladorFlowerPatch(int seed) {
		this.faladorFlowerPatch = seed;
	}

	public boolean getFaladorHerbPatchRaked() {
		return faladorHerbPatchRaked;
	}

	public void setFaladorHerbPatchRaked(boolean raked) {
		this.faladorHerbPatchRaked = raked;
	}

	public boolean getFaladorNorthAllotmentPatchRaked() {
		return faladorNorthAllotmentPatchRaked;
	}

	public void setFaladorNorthAllotmentPatchRaked(boolean raked) {
		this.faladorNorthAllotmentPatchRaked = raked;
	}

	public boolean getFaladorSouthAllotmentPatchRaked() {
		return faladorSouthAllotmentPatchRaked;
	}

	public void setFaladorSouthAllotmentPatchRaked(boolean raked) {
		this.faladorSouthAllotmentPatchRaked = raked;
	}

	public boolean getFaladorFlowerPatchRaked() {
		return faladorFlowerPatchRaked;
	}

	public void setFaladorFlowerPatchRaked(boolean raked) {
		this.faladorFlowerPatchRaked = raked;
	}

	public int getWGuildTokens() {
		return wGuildTokens;
	}

	public void setWGuildTokens(int tokens) {
		wGuildTokens = tokens;
	}

	public boolean inClopsRoom() {
		return inClops;
	}

	public void setInClopsRoom(boolean in) {
		inClops = in;
	}

	public double getDonatedAmount() {
		return donatedAmount;
	}

	public void setDonatedAmount(double amount) {
		this.donatedAmount = amount;
	}

	public ShootingStar getShootingStar() {
		return ShootingStar;
	}

	public int getZamorak() {
		return zamorak;
	}

	public void setZamorak(int zamorak) {
		this.zamorak = zamorak;
	}

	public int getSaradomin() {
		return saradomin;
	}

	public void setSaradomin(int saradomin) {
		this.saradomin = saradomin;
	}

	public int getArmadyl() {
		return armadyl;
	}

	public void setArmadyl(int armadyl) {
		this.armadyl = armadyl;
	}

	public int getCorp() {
		return corp;
	}

	public void setCorp(int corp) {
		this.corp = corp;
	}

	public int getThunder() {
		return thunder;
	}

	public void setThunder(int thunder) {
		this.thunder = thunder;
	}

	public int getGlacors() {
		return glacors;
	}

	public void setGlacors(int glacors) {
		this.glacors = glacors;
	}

	public int getSkele() {
		return skele;
	}

	public void setSkele(int skele) {
		this.skele = skele;
	}

	public int getBandos() {
		return bandos;
	}

	public void setBandos(int bandos) {
		this.bandos = bandos;
	}

	public int getNex() {
		return nex;
	}

	public void setNex(int nex) {
		this.nex = nex;
	}

	public PlayerData getPlayerData() {
		return playerData;
	}

	public int getBork() {
		return bork;
	}

	public void setBork(int bork) {
		this.bork = bork;
	}

	public int getAccountPin() {
		return accountPin;
	}

	public void setAccountPin(int pin) {
		this.accountPin = pin;
	}

	public int getQuestPoints() {
		return questPoints;
	}

	public void setQuestPoints(int questPoints) {
		this.questPoints = questPoints;
	}
	
	public long getAFKTime() {
		return afkTime;
	}
	
	public void setAFKTime(long afkTime) {
		this.afkTime = afkTime;
	}
	
	public void setAFK(boolean afk) {
		this.afk = afk;
	}
	
	public boolean isAFK() {
		return afk;
	}
	
	public AFKManager getAfkManager() {
		return afkManager;
	}
	
	public boolean isDoneTutorial() {
		return DoneTutorial;
	}

	public void setDoneTutorial() {
		DoneTutorial = true;
	}
	
	public void falseDoneTutorial() {
		DoneTutorial = false;
	}
	
	public boolean isDoneServerManager() {
		return DoneServerManager;
	}
	
	public void switchAcceptAid() {
		acceptAid = !acceptAid;
		refreshAcceptAid();
	}
	
	public void refreshAcceptAid() {
		getPackets().sendConfig(427, acceptAid ? 1 : 0);
	}
	
	public void setCastHumidify(boolean castHumidify) {
		this.CastedHumidify = castHumidify;
	}
	
	public boolean isCastHumidify() {
		return CastedHumidify;
	}
	
	public void setDoneServerManager() {
		DoneServerManager = true;
	}
	
	public void falseDoneServerManager() {
		DoneServerManager = false;
	}
	
	public static String getFormattedNumber(int amount) {
		  return new DecimalFormat("#,###,##0").format(amount).toString();
	}

	public boolean hasAcceptAid() {
		return acceptAid;
	}

}
